daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     string name; // Name of the resevoir
  12.     cout << "Name of the resevoir: ";
  13.     getline (cin,name);
  14.    
  15.     double max_capacity; // Capacity of the resevoir
  16.     cout << "Capacity of the resevoir in MAF (Millions of Acre Feet): ";
  17.     cin >> max_capacity;
  18.  
  19.     int min_inflow; // Minimum inflow of the resevoir in MAF
  20.     cout << "Minumum inflow per year of the resevoir in MAF: ";
  21.     cin >> min_inflow;
  22.  
  23.     int max_inflow; // Maxiumum inflow of the resevoir in MAF
  24.     cout << "Maximum inflow per year of the resevoir in MAF: ";
  25.     cin >> max_inflow;
  26.    
  27.     double outflow; // Minimum required outflow for the resevoir
  28.     cout << "Required outflow per year in MAF: ";
  29.     cin >> outflow;
  30.  
  31.     srand(time(0));
  32.  
  33.     int capacity = 0;
  34.     int years = 0;
  35.     int total_years;
  36.     int average_years;
  37.     for (int i = 1; i < 10; i++)
  38.     {
  39.         capacity = 0;
  40.         years = 0;
  41.         total_years = 0;
  42.         while (capacity <= max_capacity)
  43.         {
  44.             int rand_inflow = rand() % max_inflow + min_inflow; //Random value between Max and Min inflows
  45.             capacity = capacity + (rand_inflow - outflow); //How full the resevoir will be after the year
  46.             years++;
  47.         }
  48.  
  49.         total_years = += years;
  50.         average_years = total_years / 10;
  51.  
  52.         cout << "It will take " << years << " years for " << name << " to fill up." << endl;
  53.     }
  54.    
  55.     cin.get();
  56.     getchar();
  57.  
  58.     return 0;
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top