-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source.cpp
57 lines (39 loc) · 1.09 KB
/
Source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
double numberOrgs=0;
double popIncr=0;
double numberDays=0;
cout << "Enter the starting number of organisms: ";
cin >> numberOrgs;
while (!(numberOrgs >= 2))
{
cout << "The starting number of organisms must be at least 2. \n";
cout << "Enter the starting number of organisms:";
cin >> numberOrgs;
}
double runningTotal = numberOrgs;
cout << "Enter the average daily population increase (as a percentage):";
cin >> popIncr;
while (popIncr <= 0)
{
cout << "The average daily population must be a positive value. \n";
cin >> popIncr;
}
cout << "Enter the number of days they will multiply:";
cin >> numberDays;
while (numberDays < 1)
{
cout << "The number of days must be at least 1.\n";
cin >> numberDays;
}
for (int day = 1; day <= numberDays; day++)
{
runningTotal += (runningTotal * popIncr);
cout << setprecision(0) << fixed;
cout << "On day " << day << " the population size was " << runningTotal << "." << endl;
}
return 0;
}