Answer to Question #312128 in C++ for Don

Question #312128

Paula and Danny want to plant evergreen trees along the back side of their yard. They do not want to have an excessive number of trees.

Write a program that prompts the user to input the following:

  1. The length of the yard.
  2. The radius of a fully grown tree. (Use 3.14159 as the constant value for any calculations that may need \pi
  3. π).
  4. The required space between fully grown trees.

The program outputs:

  1. The number of trees that can be planted in the yard
  2. The total space that will be occupied by the fully grown trees.

Format your output with setprecision(2) to ensure the proper number of decimals for testing!




1
Expert's answer
2022-03-15T12:11:53-0400

Here is program:

int main()
{
	int lenghtyard;
	int radius;
	int required;
	float pi = 3.14159;
	cout << "Enter the length of the yard: " << endl;
	cin >> lenghtyard;
	cout << "Enter radius of a fully grown tree: " << endl;
	cin >> radius;
	cout << "Enter required space between fully grown trees: " << endl;
	cin >> required;
	cout << "The number of trees that can be planted in the yard: " << (radius + required) / lenghtyard << endl;
	cout << "The total space that will be occupied by the fully grown trees: " << radius / lenghtyard << endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment