Write a C++ program to estimate the springtime count of deer in apark for 10 con
ID: 3618396 • Letter: W
Question
Write a C++ program to estimate the springtime count of deer in apark for 10 consecutive
years.
Thepopulation of any given year depends on the previous year'spopulation according to the
following calculation:
• If the lowest winter temperature was less than 0 degrees,the deer population drops
by 15%.
• If the lowest winter temperature was between 0 degrees F and25 degrees F
(inclusive), the deer population drops by 10%.
• If the lowest winter temperature was between 26 degrees Fand 30 degrees F
(inclusive), the deer population doesn’tchange.
• If the lowest winter temperature was between 31 degrees Fand 35 degrees F
(inclusive), the deer population rises by 12%.
• If the lowest winter temperature was higher than 35 degreesF, the deer population
rises by 14%.
Input: The program should accept a starting year from the user,along with the initial deer
population. For each subsequent year in the simulation, the programshould prompt the user to
enter the lowest winter temperature.
Output: The program should print the calendar year and thepopulation during the spring.
A partial example of running such a program is shown below, withthe user's input shown
in italics.
==Deer population simulation program ==
Please enter the starting year.
1984
Please enter the starting population for the deer.
150
What was the lowest winter temperature in 1985?
-10
In1985, the deer population is 127.
What was the lowest winter temperature in 1986?
25
In1986, the deer population is 114.
What was the lowest winter temperature in 1987?
36
In1986, the deer population is 129.
...
PLEASE HELP, I WILL RATE YOU LIFESAVER
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{int year,pop,temp;
cout<<"== Deer population simulation program == ";
cout<<"Please enter the starting year. ";
cin>>year;
cout<<"Please enter the starting population for thedeer. ";
cin>>pop;
for(;;)
{cout<<"What was the lowest winter temperature in"<<++year<<"? ";
cin>>temp;
if (temp<0)
pop-=(pop*.15);
else if(temp<=25)
pop-=(pop*.10);
else if(pop<=30)
pop=pop;
else if(pop<35)
pop+=(pop*.12);
else
pop+=(pop*.14);
cout<<"In "<<year<<", the deer populationis "<<pop<<". ";
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.