Hey Guys, i'm a student in a community college and i am taking an intro to programming using c++. Any way i wrote this program to calculate reforestation rate and i need help figuring out the issue in the coding when i run the program it runs but it gets stuck on case 1 after I input the years. Case 2 is running perfectly so that isn't the issue. Thanks for the help guys.
int main()
{
//Declare objects.
int z(0),n;
double a,p,r,t,e(0),f;
while (n>=1)
{
cout<< "Press 1 if you would like to determine acres that can be harvested, " <<endl;
cout<< "given a regrowth period? " <<endl;
cout<< endl;
cout<<"Press 2 if you would like to determine regrowth period, "<<endl;
cout<<"given the acres to be harvested? " <<endl;
cin>> z;
switch (z)
{
case 1:
cout<< "Input total of acres. " << endl;
cin>> a;
cout<< "Input total acres uncut(can not be greater than total acres). " <<endl;
cin>> p;
cout<< "Input reforestation rate. "<<endl;
cin>> r;
cout<< "Input regrowth period in years. " <<endl;
cin>> t;
while (a > p);
{
e = p*pow(1+r/100,++t);
cout<< "Years " << " Acres " <<endl;
cout<< t << " " << e <<endl;
That is because your while loop is executing infintely. It runs so long as a > p, but since you never change the values of either a or p, it continues to run.