// Program: Demo7.cpp // Author: Ari // Date Written: 06/04/2008 // Purpose: Asks the user for the temperatures during an undetermined period of time // and prints the average temperature for that period of time. // #include "stdafx.h" #include <string> #include <iostream> using namespace std; // declare functions void plot(string title, int number); int main(int argc, char* argv[]) { // declare variables double temperature; double counter; double sum; // Initialize variables sum = 0; counter = 0; // Display the Program Title cout << " Average Temperature Program\n"; cout << " ---------------------------\n"; // Ask the user for a temperature. cout << "Enter the degrees Fahrenheit or -99 to quit: "; cin >> temperature; // Repeat the following instructions while age is not -99. repeat (temperature != -99); { // Increment the count for the proper age group sum = sum + temperature; counter = counter ++; // Ask for another temperature to repeat the loop cout << "Enter the degrees Fahrenheit or -99 to quit: "; cin >> temperature; } // display the report cout << endl; cout << "The average temp is: " << temperature << endl; return 0; } |
|
|