ben1234
Feb 17, 2008, 02:20 AM
Hello,
I seem to be stuck writing this program that inputs a series of 12 temperatures from the user. It should write out on the file "tempdata.dat" each temperature and the difference between the current temperature and the one preceding it. The differne is not output for the first temperature this is input. At the end of the program, the average temperature should be displayed for the user via cout. Here's the given input data:
34.5 38.6 42.4 46.8 51.3 63.1 60.2 55.9 60.3 56.7 50.3 42.2
File tempdata.dat would contain:
34.5
38.6 4.1
42.2 3.8
46.8 4.4
51.3 4.5
63.1 11.8
60.2 -2.9
55.9 -4.3
60.3 4.4
56.7 -3.6
50.3 -6.4
42.2 -8.1
This is what I have come up with so far but I got stuck as to what to do next about the computation in getting the difference between the temperatures. Can someone please help.
I seem to be stuck writing this program that inputs a series of 12 temperatures from the user. It should write out on the file "tempdata.dat" each temperature and the difference between the current temperature and the one preceding it. The differne is not output for the first temperature this is input. At the end of the program, the average temperature should be displayed for the user via cout. Here's the given input data:
34.5 38.6 42.4 46.8 51.3 63.1 60.2 55.9 60.3 56.7 50.3 42.2
File tempdata.dat would contain:
34.5
38.6 4.1
42.2 3.8
46.8 4.4
51.3 4.5
63.1 11.8
60.2 -2.9
55.9 -4.3
60.3 4.4
56.7 -3.6
50.3 -6.4
42.2 -8.1
This is what I have come up with so far but I got stuck as to what to do next about the computation in getting the difference between the temperatures. Can someone please help.