Question: Write a C + + program that will decode raw weather data in text form. Your program should read a file ( file name weatherObs.txt
Write a C program that will decode raw weather data in
text form. Your program should read a file file name weatherObs.txt and decode the information on
each line and write it for the user in a decoded, narrative format.
The input file will appear as:
MBSNWR
BAX,NS
MOP,NEDR
LAN,SEPC
AMN,SWCLD
FNTSCLR
Your output for these data should be decoded to form similar to this example:
At Saginaw, the temperature is degrees Fahrenheit degrees Celsius the dew point is degrees
Fahrenheit, winds are from the northwest at miles per hour, pressure is inches of mercury,
and it is raining.
At Bad Axe, the temperature is degrees Fahrenheit degrees Celsius the dew point is degrees
Fahrenheit, winds are from the north at miles per hour, pressure is inches of mercury, and it
is snowing.
and so on for the remaining reports.
Your program should include a driver program to read one line of coded weather data at a time as well
as a class designed to store and manage information related to one weather observation. Your class
should store all of the fields coming in from the data file defined with an appropriate data type for each.
The class should include constructors and setget functions, as required.
Extraction of the information from the raw data should be defined in the class. File processing should be
included in your main driver function. As you read a new coded weather observation, format it from the
raw form to extract all of the various fields in the appropriative data type. Invoke a function on your
weather observation object to write the narrative information for the given observation. Then, read the
next line in the file and process it the same way.
The main task to be performed as a function in your class will be to extract, or "parse", the data from
the input string, decode it and perform some conversions before you can store the information in the
member variables of your class object. Utilize the standard C string class for string processing. Be sure
your data members that are to be stored as character strings use the string class. This implies that
class composition will be included by having your weather observation class contain objects of the
standard string class.
Details on each data field are below:
Field Description
Station code
Always characters. Only a predefined list of regional weather stations will be used.
Codes for these are:
AMN Alma
BAX Bad Axe
FNT Flint
LAN Lansing
MBS Saginaw
MOP Mount Pleasant
Temperature
Provided in degrees Fahrenheit. Your output should include the equivalent Celsius
temperature. To convert,subtract from the Fahrenheit temperature and multiply the
result times
Wind
direction
Using an eightpoint compass reference. You will need to decode to write the descriptive
form to output:
N north
NE northeast
E east
SE southeast
S south
SW southwest
W west
NW northwest
Wind speed Provided in knots, or nautical miles per hour. This must be converted to miles per hour for
output. To convert, multiply knots by
Pressure
Provided in coded form with the unit of "inches of mercury". A coded value of
implies inches, a coded value of implies Pressure is always reported to
two decimal places even if they are
Weather
A code is included describing the current weather observed at the station. It will need to
be decoded for output:
CLD skies are cloudy
PC skies are partly cloudy
CLR skies are clear
R it is raining
S it is snowing
DR drizzle is reported
T a thunderstorm is reported
Design Requirement
Create the abstract data type like a structure for the "weather observation" class you are creating.
Clearly indicate the "data members" including data types or attributes of one weather observation.
Also, indicate a list of the functions that are required within the scope of this programming assignment.
Finally, include the operations on the string class necessary to extract the station code and the
temperature from one line of raw coded data.
and with this been the base
#include
#include
#include
#include
using namespace std;
int main
char Rstation;
char tempHolder;
char dewPointHolder;
char speedHolder;
char RwDirection;
char Rpressure;
char Rconditions;
open file
ifstream inFile;
inFile.openweatherObstxt;
if inFile
cout "File open error!";
exit;
process the data strings from the file using the comma delimiters
while inFile.getlineRstationeof
inFile.getlinetempHolder;
inFile.getlinedewPointHolder;
inFile.getlineRwDirection;
inFile.getlinespeedHolder;
inFile.getlineRpressure;
inFile.getlineRconditions;
output the values read from the
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
