Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <ctime>
- #include <string>
- using namespace std;
- int main()
- {
- string name; // Name of the resevoir
- cout << "Name of the resevoir: ";
- getline (cin,name);
- double max_capacity; // Capacity of the resevoir
- cout << "Capacity of the resevoir in MAF (Millions of Acre Feet): ";
- cin >> max_capacity;
- int min_inflow; // Minimum inflow of the resevoir in MAF
- cout << "Minumum inflow per year of the resevoir in MAF: ";
- cin >> min_inflow;
- int max_inflow; // Maxiumum inflow of the resevoir in MAF
- cout << "Maximum inflow per year of the resevoir in MAF: ";
- cin >> max_inflow;
- double outflow; // Minimum required outflow for the resevoir
- cout << "Required outflow per year in MAF: ";
- cin >> outflow;
- srand(time(0));
- int capacity = 0;
- int years = 0;
- int total_years;
- int average_years;
- for (int i = 1; i < 10; i++)
- {
- capacity = 0;
- years = 0;
- total_years = 0;
- while (capacity <= max_capacity)
- {
- int rand_inflow = rand() % max_inflow + min_inflow; //Random value between Max and Min inflows
- capacity = capacity + (rand_inflow - outflow); //How full the resevoir will be after the year
- years++;
- }
- total_years = += years;
- average_years = total_years / 10;
- cout << "It will take " << years << " years for " << name << " to fill up." << endl;
- }
- cin.get();
- getchar();
- return 0;
- }
Add Comment
Please, Sign In to add comment