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: The length of the yard. The radius of a fully grown tree. (Use 3.14159 as the constant value for any calculations that may need pi (π). The required space between fully grown trees. The program outputs: The number of trees that can be planted in the yard 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!
The Answer to the Question
is below this banner.
Can't find a solution anywhere?
NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?
Get the Answers Now!You will get a detailed answer to your question or assignment in the shortest time possible.
Here's the Solution to this Question
using namespace std;
/*
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:
The length of the yard.
The radius of a fully grown tree. (Use 3.14159 as the constant value for any calculations that may need \pi
The required space between fully grown trees.
The program outputs:
The number of trees that can be planted in the yard
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!
*/
int main()
{
float l, r, space;
float PI = 3.14159;
float num,totalspace,dia;
cout<<"\n\tEnter length of the yard : "; cin>>l;
cout<<"\n\tEnter Raius of fully grown trees : "; cin>>r;
cout<<"\n\tEnter the required space between fully grown trees: "; cin>>space;
num = floor(l/((2*r) + space));
if(num>0)
{
cout<<"\n\n\tNo. of Trees = "<<num;
cout<<"\n\tTotal Space occupied by "<<num<<" trees = "<<((2*r) + space);
}
else
{
cout<<"\n\n\tThe yard's length is less than the required space.";
}
return(0);
}