Hey guys I need help with this problem:
Write a C++ program to estimate the springtime count of deer in a park for 10 consecutive years.
The population of any given year depends on the previous year's population 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 and 25 degrees F (inclusive), the deer population drops by 10%.
• If the lowest winter temperature was between 26 degrees F and 30 degrees F (inclusive), the deer population doesn’t change.
• If the lowest winter temperature was between 31 degrees F and 35 degrees F (inclusive), the deer population rises by 12%.
• If the lowest winter temperature was higher than 35 degrees F, the deer population rises by 14%.
I have started with:
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
int year;
int pop1;
int pop2;
int temp;
cout<<"Please enter the starting year."<<endl;
cin>>year;
cout<<"Please enter the starting population for the deer."<<endl;
cin>>pop1;
cout<<"What was the lowest winter temperature in "<<year<<endl;
cin>>temp;
if (temp <= 0)
{pop2 = pop1 - (pop1 * 0.15);
cout << "In "<< year << ", the deer population is " << pop2 << endl;}
else if (temp <= 25);
{pop2 = pop1 - (pop1 * 0.10);
cout<< "In " <<year << ", the deer population is " <<pop2 << endl; }
int main()
{
//variables
int year;
int pop1;
int pop2;
int temp;
//prompt for input
cout<<"Please enter the starting year."<<endl;
cin>>year;
cout<<"Please enter the starting population for the deer."<<endl;
cin>>pop1;
cout<<"What was the lowest winter temperature in "<<year<<endl;
cin>>temp;
if (temp <= 0)
{
pop2 = pop1 - (pop1 * 0.15);
cout << "In "<< year << ", the deer population is " << pop2 << endl;
}
elseif (temp <= 25);
{
pop2 = pop1 - (pop1 * 0.10);
cout<< "In " <<year << ", the deer population is " <<pop2 << endl;
}
}