IN C++ FORMAT
it will have a txt file with
January 0 -10 -20 -12 February 0 20 -30 -10 March 5 45 20 32 April 25 65 45 55 May 12 75 32 66 June 18 85 65 72 July 6 98 88 90 August 18 102 82 91 September 16 85 65 73 October 12 72 45 59 November 5 62 30 45 December 0 46 -15 33
Write a program using structures to store the following weather information:
Total Rainfall
High Temperature
Low Temperature
Average Temperature
Use an the input.txt file to load the data to your array of 12 weather structures.
Once the data for all the months is entered, the program should calculate and display the:
Total rainfall for the year
Average of all of the months average temperatures.
Highest temp for the year and its months
Lowest temp for the year and its month
Validatation Input temps should be between -100 and +140 and and
total rainfall must not be less than 0
PROGRAM
#include<iostream>
#include<math.h>
#include<fstream>
#include<string>
#include<sstream>
using namespace std;
typedef struct
{
int rain;
int hightemp;
int lowtemp;
int avgtemp;
}record;
int main()
{
int i,num[50],ctr;
record weather[12];
string line;
ifstream ifile;
i=-1;
ifile.open("input.txt");
if (ifile.is_open())
{
while(getline(ifile,line,' '))
{
stringstream geek(line);
geek>>num[++i];
//cout<<num[i];
}
}
ifile.close();
ctr=0;
for(int j=1;j<i;j=j+4)
{
if (num[j]>=0)
weather[ctr].rain=num[j];
else
weather[ctr].rain=0;
if num[j+1]>=-100 && num[j+1]<=140
{
weather[ctr].hightemp=num[j+1];
}
else
weather[ctr].hightemp=0;
if num[j+2]>=-100 && num[j+2]<=140
{
weather[ctr].lowtemp=num[j+2];
}
else
weather[ctr].lowtemp=0;
weather[ctr].avgtemp=num[j+3];
ctr=ctr+1;
}
int totrain=0,totavgtemp=0,high,low,highmonth,lowmonth;
high=weather[0].hightemp;
low=weather[0].lowtemp;
for(i=0;i<12;i++)
{
//cout<<endl<<weather[i].rain;
totrain=totrain+weather[i].rain;
//cout<<endl<<weather[i].hightemp;
if(high<weather[i].hightemp)
{
high=weather[i].hightemp;
highmonth=i;
}
//cout<<endl<<weather[i].lowtemp;
if(low>weather[i].lowtemp)
{
low=weather[i].lowtemp;
lowmonth=i;
}
//cout<<endl<<weather[i].avgtemp;
totavgtemp=totavgtemp+weather[i].avgtemp;
}
totavgtemp=totavgtemp/12;
cout<<endl<<"Total rainfall of the year:"<<totrain;
cout<<endl<<"Average of the average temperature of every month:"<<totavgtemp;
cout<<endl<<"Highest temperature:"<<high;
cout<<endl<<"Month with the highest temperature:";
switch(highmonth)
{
case 0:cout<<"January";break;
case 1:cout<<"February";break;
case 2:cout<<"March";break;
case 3:cout<<"April";break;
case 4:cout<<"May";break;
case 5:cout<<"June";break;
case 6:cout<<"July";break;
case 7:cout<<"August";break;
case 8:cout<<"September";break;
case 9:cout<<"October";break;
case 10:cout<<"November";break;
case 11:cout<<"December";break;
default:break;
}
cout<<endl<<"Lowest temperature:"<<low;
cout<<endl<<"Month with the lowest temperature:";
switch(lowmonth)
{
case 0:cout<<"January";break;
case 1:cout<<"February";break;
case 2:cout<<"March";break;
case 3:cout<<"April";break;
case 4:cout<<"May";break;
case 5:cout<<"June";break;
case 6:cout<<"July";break;
case 7:cout<<"August";break;
case 8:cout<<"September";break;
case 9:cout<<"October";break;
case 10:cout<<"November";break;
case 11:cout<<"December";break;
default:break;
}
return 0;
}
INPUT FILE

*Special Note: The Input File must have single spacing between each word. If not the spaces need to be truncated.
OUTPUT

IN C++ FORMAT it will have a txt file with January 0 -10 -20 -12 February...
The following is a program from Starting out with C++ by Toni Gaddis. I am getting the following error messages pertaining to the lines: cin>>month[i].lowTemp; and months[i].avgTemp = (months[i].highTemp + month[i].lowTemp)/2; The error messages read as follows: error C2039: 'lowTemp': is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' and it continues. The second error message is identical. The program is as follows: Ch. 11, Assignment #3. pg. 646. Program #4. //Weather Statistics. //Write a program that uses a structure to store the...
1. Write a C++ program that reads daily weather observation data from a file and writes monthly and annual summaries of the daily data to a file. a. The daily weather data will be contained in a file named wx_data.txt, with each line of the file representing the weather data for a single day. b. For each day, the date, precipitation amount, maximum temperature, and minimum temperature will be provided as tab-separated data with the following format: 20180101 0.02 37...
Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays for the wind speed and for the temperature. You will then use the stored data to calculate and output the average wind speed and the average temperature. Create a constant with a value of 30 and use that to declare and loop through your arrays and as a divisor to produce your averages. Here is the data file (below). 1. 14 25 2. 12...
[C++]
Using Files—Total and Average Rainfall
Write a program that reads in from a file a starting month name, an
ending month name, and then the monthly rainfall for each month
during that period. As it does this, it should
sum the rainfall amounts and then report the total rainfall and
average rainfall for the period. For example, the output might look
like this: During the months of March–June the total rainfall was
7.32 inches and the average monthly rainfall...
Hi im having trouble with this homework question. Can someone
show me how to do this in C++ with all the steps?
Weather Analysis WeatherAnalyzer - New Day Data 2- Good Days 3- Summary 0- Exit Step 0: You can get the sample file from this link: Each row in the text file represent weather measurement of a day. For each day, the file contains the temperature (first column), humidity (second column) and the wind (third column) values emp 70...
Write a program in C++ that reads in integer numbers from a file called scores.txt until the sentinel value -999 is read. The program should then output the total and average of the numbers read and output each of the numbers incremented by the overall average to a file called or scoresout.txt along with the sentinel value of -999 at the end So if 10, 20, 30 and -999 are read in then the program would display a total of...
Write a program that scores the total rainfall for each of 12 months into an array double. A sample array definition is shown below double thisYear[] = {1.6, 2.1, 1.7, 3.5, 2.6, 3.7, 3.9, 2.6, 2.9, 4.3, 2.4, 3.7}; The program should have the four functions to calculate the following 1. The total rainfall for the year 2. The average monthly rainfall 3. The month with most rain 4. The month with least rain Output: What to deliver? Your .cpp...
Need help writing a program that meets pseudocode and criteria .
Txt File below
input.txt file data
05 11/30/16
03 12/07/16
05 12/07/16
05 12/08/16
01 12/10/16
07 12/11/16
07 12/14/16
06 12/15/16
02 12/21/16
05 12/21/16
06 12/22/16
07 12/22/16
08 12/23/16
07 12/23/16
07 12/23/16
07 12/23/16
08 12/24/16
08 12/24/16
07 12/24/16
03 12/26/16
05 12/26/16
07 12/28/16
04 12/29/16
07 01/01/17
06 01/03/17
07 01/03/17
08 01/05/17
05 01/10/17
04 01/17/17
08 01/17/17
07 01/18/17
07...
The Weather Service Bureau department has data representing monthly rainfall for a year and we would like to create a table categorizing each month as rainy (rainfall 20% higher than average) dry (rainfall 25% lower than average) or average. The data file for monthly rain fall is called rainfall.txt. rainfall.txt 95 100 120 130 135 145 155 185 190 160 130 120 Store the data file in the same folder (lab 6) of your lab6.cpp. OutputThe year's average monthly rainfall...
In Java language: Write a rainfall class that stores the total rainfall for each of 12 months of years 2015 -2017 into an 2D array of doubles. Use the text file at Actividades/Tareas link as input of rainfall data. The program should read the input data from a text file. The program should have methods that at least return the following: • Total rainfall for the years 2015 – 2017 - return a 1D array • The average monthly rainfall...