Programming Help. Can Some One Help Me Please ??

Write your question here.
Write an interactive C++ program that inputs a series of 12 temperatures from the user. It should write out on file "tempdata.dat" each temperature and the difference between the current temperature and the one preceding it. The difference is not output for the first temperature that is input. At the end of the program, the average temperature should be displayed for the use via cout. For example, given the following 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.4 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

[code]
#include <iostream>
#include <fstream>

using namespace std;
int main()
{
float current_temp, prev_temp, avg;
float t1;
float t2;
float t3;
float t4;
float t5;
float t6;
float t7;
float t8;
float t9;
float t10;
float t11;
float t12;
ofstream tempdata;
ifstream intemp;

float dift1t2;
float dift2t3;
float dift3t4;
float dift4t5;
float dift5t6;
float dift6t7;
float dift7t8;
float dift8t9;
float dift9t10;
float dift10t11;
float dift11t12;
float tempAvg;

intemp.open("intemp.dat");
tempdata.open("tempdata.dat");

intemp >> t1 >> t2 >> t3 >> t4 >> t5 >> t6 >> t7 >> t8 >> t9 >> t10 >> t11 >> t12;

dift1t2 = t1-t2;
dift2t3 = t2-t3;
dift3t4 = t3-t4;
dift4t5 = t4-t5;
dift5t6 = t5-t6;
dift6t7 = t6-t7;
dift7t8 = t7-t8;
dift8t9 = t8-t9;
dift9t10 = t9-t10;
dift10t11 = t10-t11;
dift11t12 = t11-t12;
tempAvg = (t1+t2+t3+t4+t5+t6+t7+t8+t9+t10+t11+t12)/12;

tempdata << t1 << ' ' << endl << t2 << ' ' << dift1t2 << endl << t3 << ' ' << dift2t3 << endl << t4 << ' ' << dift3t4 << endl << t5 << ' ' << dift4t5 << endl << t6 << ' ' << dift5t6 << endl << t7 << ' ' << dift6t7 << endl << t8 << ' ' << dift7t8 << endl << t9 << ' ' << dift8t9 << endl << t10 << ' ' << dift9t10 << endl << t11 << ' ' << dift10t11 << endl << t12 << ' ' << dift11t12;

cout << "The Average Temperature is " << tempAvg;

intemp.close();
tempdata.close();
return 0;
}
You did not ask a question.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
What do you mean ??
closed account (E0p9LyTq)
PLEASE, read the links:

http://www.cplusplus.com/articles/z13hAqkS/
http://www.cplusplus.com/articles/jEywvCM9/
What do you mean ??

The only question you asked was "Can someone help me?"

Yes, someone can help you, but you have to specify with what. All you did was post a problem description and a bunch of code. You did not specify what you're having problems with. We're not mind readers. Are you having problems compiling your code? If so, post the compiler error messages. Does your code compile, but not work as expected? If so, what is it doing or not doing?

Topic archived. No new replies allowed.