Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PROGRAMMING LANGUAGE IS ADA! This program will read weather data from a file and

ID: 3864144 • Letter: P

Question

PROGRAMMING LANGUAGE IS ADA!

This program will read weather data from a file and provide various summary information about that data. The format of the input file will consist of one line per day for some number of days where the line contains:

where high is the high temperature (integer) in Fahrenheit, low is the low temperature (integer) in Fahrenheit, precip is the amount of precipitation (float) in inches and date is the date in the form mm/dd/yy. You should keep reading data from the file until you encounter a line where precip is negative (this is our sentinel).

Your program should read in the data from the file and gather enough summary information to allow it to report:

Average high temperature

Average low temperature

Maximum high temperature and the date on which it occurred

Minimum low temperature and the date on which it occurred

total precipitation

How do I have it recall the variables so I can find the max and min temperature?

Explanation / Answer

You don't need to recall the variables as such, just store the maximum and minimum of temperature in a variable till the point you have read by comparing the values till last line and replacing them if they satisfy the condition.

i.e.

if high > maxHighTemp then

maxHighTemp : high;

maxHighTempDate : date;

end if;

if low < minLowTemp then

minLowTemp : low

minLowTempDate : date;

end if;

for example, let the file have data

10 5 2 11/10/2016

11 6 2 11/11/2016

9 7 2 11/12/2016

Then let say after reading a line you store these values in high, low, precip and date respectively in a loop. Then maintain separate variables for Average high temperature -->avgHighTemp, Average low temperature --> avgLowTemp, Maximum high temperature and the date on which it occurred ---> maxHighTemp and maxHighTempDate , Minimum low temperature and the date on which it occurred --> minLowTemp and minLowTempDate, total precipitation totalPrecipiation.

And do

so at line 2 , high = 11 , low = 6 whereas from line 1 maxHighTemp -> 10 and minLowTemp = 5.

so 11 > 10 , is true maxHighTemp = high i.e. maxHighTemp = 11 and similarly minLowTemp remains 5. Do this for every line by using a loop and at the end of the file you will your result

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote