Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write C + + program Based on the lengthy description provided, here s a breakdown of what you should do and the classes you need
Write C program
Based on the lengthy description provided, heres a breakdown of what you should do and the classes you need to create for your C program, along with their requirements. This setup is intended for managing and processing weather station data, specifically focusing on wind speed:
Objective:
Your primary task is to write a C program that reads weather data from a CSV file, computes the average wind speed and its standard deviation, and identifies entries in the data that match the computed average wind speed. The data structure used for managing this data will be essential for handling and processing the information efficiently.
Classes and Data Structures:
Required Classes:
Date Class: This class should already exist from a previous lab. It is used to manage date values extracted from the data file.
Time Class: This needs to be created. It should store and manage time values.
Vector Template Class: This class represents a dynamic array capable of storing any data type. For this specific task, it will store instances of WindRecType.
WindRecType Struct:
This is a struct, but you should consider whether a class might be more appropriate depending on the complexity of operations and encapsulation required. For simple data storage, a struct is adequate.
Fields:
Date d; Date of the data entry.
Time t; Time of the data entry.
float speed; Wind speed in meters per second.
Vector Realization:
WindlogType: This is a typedef definition for Vector. It will be the primary data structure for storing wind records.
Functionality Requirements:
Reading Data: Your program must be able to read data from a CSV file, parse it and populate instances of WindRecType which are then stored in WindlogType.
Data Processing:
Calculate the average wind speed in kmh and the sample standard deviation of the wind speeds.
Identify and print the date and time for entries that match the computed average wind speed. Note that matching floating point numbers requires consideration of precision, so a tolerance level should be set for what constitutes a match.
Handling Different Data Formats:
The program should be robust against changes in the order of columns in the CSV file. The identification of columns should be based on headers rather than fixed positions.
Error Handling:
Handle potential erroneous or missing data egNA values for offline sensors gracefully. These should not be included in the calculations for average or standard deviation.
Debugging and Validation:
Before loading the entire dataset, test the reading and parsing functions with a small subset of data to ensure correctness.
Output the parsed data to another CSV file testoutputcsv and manually verify this output by comparing it to the source file in a spreadsheet or text editor.
Implementation Considerations:
Consider the use of classes versus structs. For simple containers that just hold data without requiring methods or encapsulation, structs are adequate. If more functionality or encapsulation is needed, use classes.
Ensure your classes are designed with high cohesion and low coupling, focusing on making them reusable and maintainable.
Testing and Validation:
Test the program's output against manual calculations like using spreadsheet formulas to ensure the calculations for average and standard deviation are correct.
Use comprehensive debugging to confirm the data is read and stored correctly before moving on to the calculation phase.
Below are my Date class
lass Date
public:
@brief Default constructor initializes a new Date object.
Constructs a Date with all components set to their default values.
Date;
@brief Construct a new Date object with specified day, month, and year.
@param day Day of the month.
@param month Name of the month.
@param year Year component.
Date unsigned day, const string& month, unsigned year ;
@brief Retrieves the day of the month.
@return Day as an unsigned integer.
unsigned GetDay const;
@brief Sets the day of the month.
@param day Day of the month to be set.
void SetDay unsigned day;
@brief Retrieves the name of the month.
@param month Reference to a string to store the retrieved month.
void GetMonthstring &month const;
@brief Sets the name of the month.
@param month String representing the new month.
void SetMonthconst string &month;
@brief Retrieves the year component.
@return Year as an unsigned integer.
unsigned GetYear const;
@brief Sets the year component.
@param year Year to be set.
void SetYear unsigned year;
private:
int mday;
string mmonth;
int myear;
;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started