Can someone help me fix this code please???The days do increase but the organisms stay the same for each day....
question: Write a program that will predict the size of a population of organisms. The program
should ask the user for the starting number of organisms, their average daily population
increase (as a percentage of current population), and the number of days they will multiply.
A loop should display the size of the population for each day.
Input Validation: Do not accept a number less than two for the starting size of the
population. Do not accept a negative number for average daily population increase.
Do not accept a number less than one for the number of days they will multiply.
#include <iostream>
#include <iomanip>
usingnamespace std;
int main()
{
int Organisms, Growth, Days;
int Day = 0;
do
{
cout << "Please enter the starting number of orgranisms: ";
cin >> Organisms;
if (Organisms < 2)
{
cout << "The starting number of organisms must be atleast 2\n";
}
}
while (Organisms < 2);
do
{
cout << "Please enter the amount of days to multiply: ";
cin >> Days;
if (Days < 1)
{
cout << "The amount of days must be greater than 1.\n";
}
}
while (Days < 2 );
do
{
cout << "Please enter the daily average population increase: ";
cin >> Growth;
if (Growth < 0)
{
cout << "The amount of growth must be greater than 0.\n";
}
}
while ( Growth < 0);
Growth/= 100;
cout << "Day Number of Organisms: " << endl;
do
{
cout << setw(2) << Day << setw(20) << Organisms << endl;
((1 + Growth) * Organisms);
Organisms = Organisms * (1 + Growth);
Day++;
}
while ( Day <= Days );
system ("Pause");
return 0;
}
Well, your last while loop will never execute because you're only running it while growth is <0, but you force the user to enter a value >0. Try swapping that sign around.