I'm not sure how to approach this problem.. mostly with the while statement..
Download the original attachment

The Problem:
Write a program on timber regrowth of a harvested forest. The user is to enter the total number of acres in the harvested area, the number of acres which were left uncut, and the reforestation rate. The program will then determine how many years are required for the number of cut acres to be completely restored. Your program should display the initial conditions, and display the progress made as each year passes in a table.

It is assumed that reforestation takes place at a known rate per year, depending on soil and climate conditions. A reforestation equation states this growth as a function of the amount of timber standing and the reforestation rate. So for year x, the total reforested acres of timber = (starting total forested acres for year x -1) times (reforestation rate), so if the starting total forested acres for year x -1 is 1000, and the reforestation rate is .04, then the total reforested acres of timber for year x = 1000 + 1000 * .04 or 1040 acres, for year x + 1, the total would be 1040 + 1040 * .04 or 1081.6 acres.


Example:

Enter total acres: 12000
Enter acres uncut: 3000
Enter reforestation rate: .04

Year Forested Acres
0 3000.00
1 3120.00
2 3244.80
3 3374.59
... ...
36 12311.80


hERE IS WHAT I HAVE

#include <iostream.h>
main ()


{
	int total, uncut;
	rate = 0.04;   THIS IS THE KNOWN RATE PER YEAR

	cout << "Enter total acres:\n";
	cin >> total;
	cout << "Enter acres uncut:\n";
	cin >> uncut;
	




return 0;
}

I'm not sure how to approach this problem.. mostly with the while statement..
Download the original attachment

The Problem:
Write a program on timber regrowth of a harvested forest. The user is to enter the total number of acres in the harvested area, the number of acres which were left uncut, and the reforestation rate. The program will then determine how many years are required for the number of cut acres to be completely restored. Your program should display the initial conditions, and display the progress made as each year passes in a table.

It is assumed that reforestation takes place at a known rate per year, depending on soil and climate conditions. A reforestation equation states this growth as a function of the amount of timber standing and the reforestation rate. So for year x, the total reforested acres of timber = (starting total forested acres for year x -1) times (reforestation rate), so if the starting total forested acres for year x -1 is 1000, and the reforestation rate is .04, then the total reforested acres of timber for year x = 1000 + 1000 * .04 or 1040 acres, for year x + 1, the total would be 1040 + 1040 * .04 or 1081.6 acres.


Example:

Enter total acres: 12000
Enter acres uncut: 3000
Enter reforestation rate: .04

Year Forested Acres
0 3000.00
1 3120.00
2 3244.80
3 3374.59
... ...
36 12311.80


hERE IS WHAT I HAVE

#include <iostream.h>
main ()


{
	int total, uncut;
	rate = 0.04;   THIS IS THE KNOWN RATE PER YEAR

	cout << "Enter total acres:\n";
	cin >> total;
	cout << "Enter acres uncut:\n";
	cin >> uncut;
	




return 0;
}

Remember that you have an initial value that is constantly going up by the following equation--

value = value + value * .04;

That's a key ingredient in your code. Either that or you can use--

value *= 1.04;

Which will multiply the current value by itself and 1.04 and store it in value. You'll have to do this many times to account for the time taken for full reforestation.


You'll have to keep doing this until all of the trees are grown back. Basically you'll have to think of a way to stop this totaling with some kind of sentinel to determine when you've reached 12000 acres.

With that said, you should be able to get started!

OK..
here is what i have now.
//This program will calculate the reforestation rate in years to

//restore a forest that has been partially harvested.

#include <iostream>

#include <iomanip>

using namespace std;



int main()

{

      int year;

      double total = 0.0, totalAcres, uncut, reforestAcres; SHOULD THIS BE JUST 
      INT TOTALACRES, UNCUT;
      AND 
      0.04 = REFORESTATION;

      double rate;

      

      cout << "Enter the number of acres harvested:\n";

      cin >> totalAcres;

      cout << "How many arces are left uncut?" << endl;

      cin >> uncut;

      cout << "What is the reforestation rate?" << endl;   WITH THIS PART DELETED BECAUSE THE RATE IS ALREADY DEFINED??

      cin >> rate;

      cout << "Year           Forested Trees" <<endl;

      cout << "--------------------------\n";

      while(uncut = 3000, year++, reforestAcres+= (uncut + uncut * rate),  I AM NOT SURE ABOUT USING THIS PART... THE COUNTING I DON'T THINK IS CORRECT???

         reforestAcres <= totalAcres)   

         cout << year << "\t\t" << reforestAcres++ << endl;

      

      system("pause");

      return 0;

}

you can use the loop this way

while (/*you have not reached the max*/)
{
     //insert your code here
}

or you can do this

do
{
    //insert your code here

}while(/*limit is not reached*/)

You would need the first loop if you dont want anything to be done if the condition has been met and you can use the second loop if u want the code to run atleast once before the condition is met

First: You should use code-tags when posting code.

line 17 of your code: INT TOTALACRES; C++ is 'case sensitive'. That means that 'INT' and 'int' are not the same thing. This should give you a compilererror.

You can't place comments in the code like that. Use /* comment here */ or // comment here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.