Your next programming assignment at the Research Center is to write a program that reads data from a file and produces a report of rainfall for that period of time. The program should read the starting month name from the data file, then read an ending month name, followed by reading in monthly rainfall amounts for each of the months from the starting month through the ending month. As it reads the monthly totals, it should sum (accumulate) the rainfall amounts and then eport the total rainfall and average rainfall for the period. For example, if the starting month name is January and the ending month is March, and the rainfall amounts are 2.55, 3.45 and 4.0, then th eoutput might look like this: During the months of January-March, the total rainfall was 10.00 inches and the average monthly rainfall was 3.33 inches. Data for the program is located in the file attached below (rainfall.txt). You may modify this data file to include more months, but make sure that you have a rainfall amount for each month (if you use January and December for the month names, you MUST have 12 rainfall amounts in your data file. Hint: After reading in the two month names, you will need to read in rain amounts until the EOF is reached and, as you read in each amount, add 1 to the count of how many pieces of rain data you read in. This will help with the average calculation. DO NOT assume there will always be 5 values in the file.
rainfall.txt
ouput:
April
August
1.16 2.02 1.34 1.51 .30
C++ programming language
Code
#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
ifstream in;
string startMonth, endMonth;
double sum=0, avg, rainFall;
int count=0;
in.open("rainfall.txt");
if (!in)
{
cout << "ERROR: Can't opent
the file. Exiting....." << endl;
return 0;
}
cout << fixed << setprecision(2);
in >> startMonth;
in >> endMonth;
while (!in.eof())
{
in >> rainFall;
sum += rainFall;
count++;
}
avg = sum / count;
cout << "During the months of " <<
startMonth << "-" << endMonth << " the total
rainfall was " << sum << " inches and the average
monthly rainfall was " << avg << " inches" <<
endl;;
system("pause");
return 1;
}
outputs
rainfall.txt

output

rainfall.txt

output
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
Your next programming assignment at the Research Center is to write a program that reads data...
[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...
qbasic is the programming language
Chapter 8 Do Programming Exercise 8-3 om page 414. Create a string array to hold the months of the year. Call it anything you want to just make sure it's a string array is at the end of the name, e.g. months). Create a DATA statement that holds the month names: DATA "jan","Feb", "Mar" etc. Next you'll need a FOR loop to READ the DATA into the array, Call a SUB to get the rainfall...
I was wondering if I could get some help on the last program I need to complete for an engineering C++ class. It is a very simple program however there is one part of the problem stumping me. Here is the problem statement . Write a C++ program that reads in from a file two month names, followed by the rainfall amounts for each month in that span of months. These rain amounts are totaled, and then an average for...
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...
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...
use vc++ to complete the programming project....
Number Array
Version 1 (all interactive). Write a program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months. The program then prints out a nicely formatted table showing the rainfall for each of the previous 12 months as well as how much above or below average the rainfall was for each...
Directions: Write a code for the following programming exercise in PYTHON!!!!!!! -Design a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Here is what i got so far, but for some reason this code only print the Minimum and Maximum. its not printing the Average. def...
how to make this program for c++ visual studio 2015. Also, can I
show your working and program. Also, Can you have notice for pseudo
code?
For the first problem, please implement Problem 4 on page 142 (p 143, 7E) of the text. A scan of the problem is provided below. This problem asks you to calculate the average rainfall for three months. The program should ask the user to enter the name of each month, such as June or...
Rainfall StatisticsWrite a modular program that analyzes a year's worth of rainfall data. In addition to main, the program should have a getData function that accepts the total rainfallfor each of 12 months from the user, and stores it in a double array. It should also have four value-returning functions that compute and return to main thetotalRainfall, averageRainfall, driestRainfall, and wettestMonth. These last two functions return the number of the month with the lowest and highest rainfall amounts,not the amount...
Write a Python program that allows the user to enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest rainfall amounts. Data: January: 8.9 inches February: 11.1 inches March: 13.4 inches April: 6.9 inches May: 8.7 inches June: 9.1 inches July: 15.9 inches August: 4.4 inches September: 3.1 inches October: 5.6 inches November: 7.8...