Question: 1) Write a program that reads data from a text file that contains information about the rainfall amounts during a specific period and reports the

 1) Write a program that reads data from a text file

1) Write a program that reads data from a text file that contains information about the rainfall amounts during a specific period and reports the total and average rainfall for the specified period. The text file will have the year, start month, and end month of the period the first three lines of the file and then the rainfalls amounts in that period. Hint: First read the year, start and end months from the text file. Then you need a while loop to read the rainfall amounts A sample text file data content may look like below. 2016 March 1.34 1.02 1.51 Then, your program should produce a report similar to below and print the report to the screen as well as to an output text file During March-May 2016 total rainfall was: 3.17 average rainfall was: 0.79 Save your program as Lab2-1-yourName.cpp to submit. 2) Update your program in (1) above by adding two functions to your program such that you have i) one function to read data from the input text file and calculate the total and the average i) and another function to write (save) data to an output text file The prototypes of the functions will look like below. Your job is to write the body of these functions and use (call) these function in your main program to complete the required task. The skeleton for the main function is provided under the Lab Files folder in Blackboard. textbook // this function will read the data from input text file referred by intile // and calculate the total and average rainfal1s // and save the data read from the text file in the // reference parameters (total, average, year, startMonth, endMonth) void readData (ifstream sinFile, double stotal, double saverage, int syear, string sstartMonth Download the file to start this project. Hint See Section 6.13 in particular sub section Passing Files to Functions: page 374 of the string iendMonth) : // this function wi11 save the report to an output text file referred by out File void saveData (ofstream coutFile, double total, double average, int year, string startMonth, string endMonth)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!