Question

In: Computer Science

Paula and Danny want to plant evergreen trees along the back side of their yard. They...

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.

The required space between fully grown trees.

The program outputs the number of trees that can be planted in the yard and the total space that will be occupied by the fully grown trees.

Solutions

Expert Solution

Provided code is done as per your requirements.

  • "Screen shot program code" for better understanding.
  • "Code to copy" for run the program in your IDE.

Code Image:

Sample Output:

Code to Copy:

#include <iostream>

using namespace std;

int main()

{

// declare variables as double type

double lengthofYard;

double radius;

double spaceBetween;

double areaofTrees = 0;

double numberofTrees;

// Declare count as integer type variable.

int count = 0;

// Prompt the user to enter the length of the yard.

cout << "Enter the length of the yard: ";

cin >> lengthofYard;

// Prompt the user to enter the radius of the fully grown tree.

cout << "Enter the radius of a fully-grown tree: ";

cin >> radius;

//Prompt the space between the fully-grown trees from user

cout << "Enter the space between the fully grown tree: ";

cin >> spaceBetween;

//calculate number of trees

numberofTrees = lengthofYard /spaceBetween;

//calculate areaofTrees

areaofTrees = 3.14*radius*radius*numberofTrees;

// Display the total Space occupied by the full grown trees.

cout << "The total space occupied by fully grown trees is: " << areaofTrees<<endl;

return 0;

}


Related Solutions

IN C++ please Paula and Danny want to plant evergreen trees along the back side of...
IN C++ please 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...
A gardening services where hired to plant M’s back yard. By mistake they went and planted his neighbor’s Back yard.
Business lawA gardening services where hired to plant M’s back yard. By mistake they went and planted his neighbor’s Back yard. The neighbor saw them starting their work and said nothing. When they asked the neighbor for their payment he refused and said he did not hire them. What type of contract is this? Is itlegally binding? Explain
Mandeep’s parents want to build a rectangular ice rink in the family’s back yard with an...
Mandeep’s parents want to build a rectangular ice rink in the family’s back yard with an area of 200m2 What are the dimensions that will minimize the amount of material required to build the boards around the rink? If the material for the boards can be bought for $1.75 a linear foot, how much will it cost to build the boards? Trevor was given 15 square concrete stones with a 1 ft. side length. He decides to make a slab...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT