Share Pastebin
Guest
Public paste!

Graeme

By: a guest | Feb 9th, 2010 | Syntax: C++ | Size: 0.87 KB | Hits: 14 | Expires: Never
Copy text to clipboard
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8.     int number;
  9.     double temp, sum, maximum, minimum, ptemp;
  10.     string name;
  11.  
  12.     cin >> name;
  13.     while (name != "XXX")
  14.         {
  15.     number=0;
  16.     sum=0;
  17.  
  18.  
  19.     cin >> temp;
  20.  
  21.     maximum = temp;
  22.     minimum = temp;
  23.  
  24.     while (temp != -999)
  25.         {   if(temp > maximum)
  26.             {   maximum = temp;
  27.             }
  28.  
  29.             if (temp < minimum)
  30.             {   minimum = temp;
  31.             }
  32.  
  33.             sum = sum + temp;
  34.             number = number + 1;
  35.  
  36.             cin >> temp;
  37.             }
  38.  
  39.  
  40.     cout << "Name = " << name << endl;
  41.     cout << "Maximum = " << maximum << endl;
  42.     cout << "Minumum = " << minimum << endl;
  43.     cout << "Average Temp. = " << sum/number << endl;
  44.  
  45.     cin >> name;
  46.         }
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.     system("PAUSE");
  54.  
  55.     return 0;
  56. }