Ask Experts Questions for FREE Help !
Ask
    SammiD08's Avatar
    SammiD08 Posts: 1, Reputation: 1
    New Member
     
    #1

    Feb 1, 2009, 07:32 AM
    Writing a program that outputs this information
    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

    Be sure to use proper formatting and appropriate comments in your code. The input should have appropriate prompts, and the output should be labeled clearly and formatted neatly.

    I've been looking at this problem for the past week... PLEASE HELP!!
    JoshP's Avatar
    JoshP Posts: 1, Reputation: 1
    New Member
     
    #2

    Feb 7, 2009, 10:50 PM
    Hope this helps some what. Output for this will give you the temps, difference between temps and the average temps. As for the file output, don't know that much c++.

    Code:
    #include <iostream>
    using namespace std;
    
    int main() {
        double tempt, temp[12];
    
        cout << "Enter a temps:" << endl;
    
        //Get the temps.
        for (int i = 1; i <= 12; i++) {
            cin >> temp[i];
        }
    
        cout << temp[1] << endl;
        //Get the diff betweek the temps.
        for (int i = 2; i <= 12; i++) {
            cout << temp[i] << " " << temp[i] - temp[ i - 1] << endl;
        }
    
        //Get the sum of the Temps, and avarage it out.
        for (int i = 1; i <= 12; i++) {
            tempt += temp[i];
        }
        cout << "Avargae = " << tempt / 12 << endl;
    
        return 0;
    }

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Affiliate Program Information Manager [ 2 Answers ]

I am looking for a good software program to maintain and monitor various information collected from numerous Internet Affiliate Marketing Programs which I have joined and am now actively promoting. Any suggestions would be most welcome. Please give name of software program and why you like...

I just want to know p are in writing minutes and what really writing [ 3 Answers ]

I just want to know the procedures in writing minutes and what really entails in writing minutes.

3 outputs, 3 monitors, one at a time, none work! [ 5 Answers ]

I've had a computer sitting dormant for a few months, it's all hooked up and I was using it at one time. Recently I tried firing it up cause I needed something on it and when I booted it up, the monitor turned off after the loading screen. This happened several times after many restarts. I tried...

Advice about a career I want to get into (And information technology program) [ 1 Answers ]

Hi I was wanting to take a information technology specialist program and I was wondering if you could tell me what you think of it. Do you believe that the courses I am taking aren't very good for the 3300 cdn that I am paying for them or do you think I should find another course or do you think...


View more questions Search