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 program outputs:
Format your output with setprecision(2) to ensure the proper number of decimals for testing!
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);
}
Comments
Leave a comment