A) your names are wayyyy to similar:
new_Population (the parameter in int main)
new_population (the function)
new_population (the local parameter in new_population()
B) You return 0 in your new_population function, you should return the result
C) You should set initial_population = new_Population so that it changes for each year
# include <iostream>
int new_population (int, double, double) ;
usingnamespace std;
int main ()
{
int initial_population, years, new_Population;
double birth_rate, death_rate;
cout << " Please enter the starting size of the population : " << endl;
cin >> initial_population;
cout << " Annual birth rate : " << endl;
cin >> birth_rate;
cout << " Annual death rate : " << endl;
cin >> death_rate;
cout << " Numbers of years : " << endl;
cin >> years;
for (int i = 0; i < years ; i ++ )
{
new_Population = new_population ( initial_population, birth_rate, death_rate) ;
initial_population = new_Population; // Set this for the next iteration
}
}
int new_population ( int initial_population, double birth_rate, double death_rate)
{
// Changed the name of the local variable here
int output = initial_population + birth_rate - death_rate;
cout << " New population is " << output << endl;
return output; // No longer returning 0;
}
You never set the computer's choice. You use an uninitialized variable meaning that the computer may as well have chosen a rubber duck.
add this to give the computer a random number between 0 and 2 (inclusive): computer_choice = rand()%3;
You'll need to include <cstdlib> for this.
Finally, to get full marks, I suspect that you'll have to select a winner. That's easy to do since you already have tons of else-if statements comparing the computer to the player. Just stick it in there.