Starting from:
$30

$24

Lab 6 Dynamic Arrays/Files Solution




PROGRAM SPECIFICATIONS




Meteorologists love to keep statistics on the weather. They often tell us the maximum temperature for some date, or the minimum value for some date, or even how long it has been since Spokane experienced a 60 degree day. Your task is to use dynamic arrays provide some of the same statistics that a meteorologist does.




Your task:







Your data will come from a file named temps.txt – My code prompts the user for the filename.



The first line in the file will contain the number of days



The file will then contain that number of entries for the number of days, one per line.



Create an array of the exact size needed



Fill the array with the values from the file.



Repeatedly display the menu that has the following choices



Find and display the max temperature



Find and display the min temperature



Find and display the mean (average) temperature for the month



Find and display the median temperature for the month



Find and display the mode temperature for the month – if all the same then the lowest temp
Allow the user to load a new file



Quit



You must range check menu entries




I have provided cscd240Lab6.c – As always you can’t change my main




TO TURN IN







A zip file that contains Lab6 folder and: - You better know the naming scheme by now




All your code required to compile and execute your program



A valgrind run to show you don’t leak memory named cscd240lab6val.txt



An output run of your program named cscd240lab6out.txt
At least 2 runs over your program and make sure you test everything
SAMPLE RUN / SAMPLE FILE




28

12

14

12

10

-2

-5

12

14

16

18

20

22

21

23

15

12

10

18

19

20

21

22

23

24

25

26

27

28




Welcome to the Weather Program




I have read that there are 28 temperatures.




Please choose from the following:




Display the max temperature
Display the min temperature



Display the mean temperature for the month



Display the median temperature for the month



Display the mode temperature for the month



Load a new file



Quit



Choice -- -2




Invalid selection please try again

Please choose from the following:




Display the max temperature



Display the min temperature



Display the mean temperature for the month



Display the median temperature for the month



Display the mode temperature for the month



Load a new file



Quit



Choice -- 1




The maximum temperature was: 28




Please choose from the following:




Display the max temperature



Display the min temperature



Display the mean temperature for the month



Display the median temperature for the month



Display the mode temperature for the month



Load a new file



Quit



Choice -- 2




The minimum temperature was: -5







Please choose from the following:




Display the max temperature
Display the min temperature



Display the mean temperature for the month



Display the median temperature for the month



Display the mode temperature for the month



Load a new file



Quit



Choice -- 4




I have read that the temperatures are for March and there are 31 temperatures.




Please choose from the following:




Display the max temperature
Display the min temperature



Display the mean temperature for the month



Display the median temperature for the month



Display the mode temperature for the month



Load a new file



Quit



Choice -- 3




The average temperature was: 25.6 degrees

More products