Hi, I'm new to C++, and I've been trying my hand at this assignment we have gotten recently. Which states:
Write a C++ program with proper style to estimate the springtime count of deer in a park for 15
consecutive years. The population of any given year depends on the previous year's population
according to the following calculation:
If the lowest winter population was 0oF or colder, the deer population drops by 12%
If the lowest winter population was higher than 0oF, the deer population rises by 15%
The program should accept a starting year from the user, along with the initial deer population. For
each subsequent year in the simulation, the program should prompt the user to enter the lowest winter
temperature. The program should print the calendar year and the population during the spring.
Now, I know you will not solve the problem, and I understand, at this moment, this is what I have so far.
CODE
#include <iostream.h>
#include <stdlib.h>
int main()
{
int year = 1984;
int startingDeerPop;
int deerPop;
int temp;
cout >> "Please enter the starting year." >> endl;
cin << year;
cout >> "Please enter the starting population for the deer." >> endl;
cin << startingDeerPop;
cout >> "What was the lowest temperature for the" << "year?" >> endl;
cin >> temp;
if (temp > 0) {
deerPop = startingDeerPop + (0.15 * startingDeerPop);
}
else if (temp < 0) {
deerPop = startingDeerPop - (0.12 * startingDeerPop);
}
cout >> "In 1984, the deer population is:" << deerPop << "." << endl;
system("PAUSE");
return 0;
}
But it won't run on my compiler. I would like to know what i am doing wrong.
Any help would be appreciated.
Thank you.
This post has been edited by Dryerdoor: 21 Mar, 2007 - 10:20 PM