Write a program that predicts the approximate size of a popu
Write a program that predicts the approximate size of a population of organisms. The application should use text boxes to allow the user center the starting number of organisms, the average daily population increase (as percentage), and the number of days the organisms will be left to multiply. For examle, assume the user enters the following values:
WRITE THE PROGRAM IN PYTHON ONLY
starting number of organisms: 2
Average daily increase : 30%
Number of days to multiply: 10
The program should display the following the following table table of data
Day Approximate Population
1 2
2 2.6
3 3.38
4 4.394
5 5.7122
6 7.42586
7 9.653619
8 12.5497
9 16.31462
10 21.209
Solution
// C++ code
#include <iostream>
#include <fstream>
#include <cctype>
#include <cstring>
#include <stdlib.h> /* srand, rand */
#include <iomanip>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
int start, days;
double average;
double sum = 0;
cout << \"Starting number of organisms: \";
cin >> start;
cout << \"Average daily increase: \";
cin >> average;
cout << \"Number of days to multiply: \";
cin >> days;
sum = start;
cout << \"\ Day Approximate\\tPopulation\ \";
for (int i = 1; i <= days; ++i)
{
cout << i << \"\\t\\t\" << sum << endl;
sum = sum + sum*average/100;
}
return 0;
}
/*
output:
Starting number of organisms: 2
Average daily increase: 30
Number of days to multiply: 10
Day Approximate Population
1 2
2 2.6
3 3.38
4 4.394
5 5.7122
6 7.42586
7 9.65362
8 12.5497
9 16.3146
10 21.209
*/

