Question

C++ programming: Paula and Danny want to plant evergreen trees along the back side of their...

C++ programming:

Paula and Danny want to plant evergreen trees along the back side of their yard. they do not want to have excessive number of trees. write a program that prompts that the user to put 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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C ++ code for the above question is below : -

#include <iostream>

using namespace std;

int main()
{
int length,radius,space; //varirable declarations
cout<<"enter the length of the yard: ";
cin>>length; //getting length of the yard as input from user
cout<<"enter the radius of a fully grown tree: ";
cin>>radius; //getting the radius of fully grown tree from user
cout<<"enter the required space between fully grown trees: ";
cin>>space; //getting the space between trees from user
  
// the number of trees that can be planted in the yard and
// the total space that will be occupied by the fully grown trees.
  
int number_of_trees = length/(2*radius + space ); //number of trees which can be planted in yard
cout<<"The number of trees that can be planted in the yard are : "<<number_of_trees<<endl;
// space occupied by trees will be equal to their diameter * number of trees
cout<<"The total space that will be occupied by the fully grown trees : "<< number_of_trees*(2*radius)<<endl;
  
return 0;
}

code screenshot : -

output : -

if my answer helped then please upvote and comment for any queries

Thankyou !

Add a comment
Know the answer?
Add Answer to:
C++ programming: Paula and Danny want to plant evergreen trees along the back side of their...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is in C. For this assignment we will write a simple database server. We will...

    This is in C. For this assignment we will write a simple database server. We will be creating a simple database of student records, so let’s describe these first. The format of a student record is as follows: typedef struct student {     char lname[ 10 ], initial, fname[ 10 ];     unsigned long SID;     float GPA; } SREC; Part One – the Server We will create a database server. The job of the server is to accept a...

  • LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check...

    LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check the output) Display the command(s) used to do the following: create an empty file called history by using just a redirection operator. Verify and show. Show/verify all results (i.e., all commands and their corresponding outputs). Wait 1 minute or more and then display the command(s) used to do the following: change the timestamp on the history file you just created. Verify/display the change. Show/verify...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT