Question

In: Computer Science

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 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!

When the input is: 200, 8, 24

The output should be: Enter the length of the yard:


200
Enter the radius of full grown tree:
8
Enter the gap between trees:
24
Total Number of trees: 5
Area covered by trees: 1005.31

Solutions

Expert Solution

#include <iostream>
#include <iomanip>

using namespace std;

int main() {

        int len, radius, gap;
        cout << "Length of yard: ";
        cin >> len;
        cout << "Enter the radius of fully grown tree: ";
        cin >> radius;
        cout << "Enter the gap between trees: ";
        cin >> gap;

        int numTrees = 0;
        
        if(gap >= 2*radius) {
                //len = len - 2*radius;
                //numTrees++;

                numTrees += (len / (2*radius + gap));
        }

        cout << "numTrees: " << numTrees << endl;
        cout << "Area covered: " << (numTrees * 3.14159 * radius * radius) << endl;
}

**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

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...
Subject: Homework - Family Trees please give me C codes, thanks FAMILY TREE In a Binary...
Subject: Homework - Family Trees please give me C codes, thanks FAMILY TREE In a Binary Tree, each node has two children at most. To eliminate the restriction by linking the children together to form a list. In this design, each node in the tree needs to contain only two pointers: one to its eldest child and one to its next younger sibling. Using this representation, in each node, the pointer on the left always points down to child; the...
PLEASE DO THIS IN C#: Back in my Day! Kids who grew up in the late...
PLEASE DO THIS IN C#: Back in my Day! Kids who grew up in the late 70s didn’t have a lot of options for video games, but they did have “Choose your own Adventure” books. These books were cool and let the reader make meaningful decisions. If they chose choice “A”, they would turn to a page of the book and continue their adventure. If they chose choice “B”, they would turn to a different page and read a different...
please do this in C++! I want to understand it, it must be done before the...
please do this in C++! I want to understand it, it must be done before the evening or nightime. Follow instructions exactly as it says. Please send a screenshot also with your code so I can see how it is supposed to be formatted. Since typing it a chegg answer, makes it look a bit messy. Your program will read in a file of commands. There are three types of commands: Warrior creates a new warrior with the specified name...
PLEASE CREATE A PROGRAM IN PSEUDOCODE AND C# Back in my Day!  Kids who grew up in...
PLEASE CREATE A PROGRAM IN PSEUDOCODE AND C# Back in my Day!  Kids who grew up in the late 70s didn’t have a lot of options for video games, but they did have “Choose your own Adventure” books.  These books were cool and let the reader make meaningful decisions.  If they chose choice “A”, they would turn to a page of the book and continue their adventure.  If they chose choice “B”, they would turn to a different page and read a different adventure.  Your...
please i want solution for this question with algorithm and step by step with c++ language...
please i want solution for this question with algorithm and step by step with c++ language write a program using for loop that calculates the total grade for N classroom exercises as a percentage. The user should input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total points possible) and output it as a percentage. Sample input and output is shown below.How...
I want a unique c++ code for the following. PLEASE HIGHLIGHT THESE FUNCTIONS WITH COMMENTS ....
I want a unique c++ code for the following. PLEASE HIGHLIGHT THESE FUNCTIONS WITH COMMENTS . Add the following functions to the class arrayListType: Then, update the main function to test these new functions. removeAll - which removes ALL of the instances of a value in the list min - which returns the minimum value in the list max - which returns the maximum value in the list arrayListType.h : #ifndef H_arrayListType #define H_arrayListType class arrayListType { public: bool isEmpty()...
Please give answer and refrence to back you work. 1. According to C. Wright Mills, what...
Please give answer and refrence to back you work. 1. According to C. Wright Mills, what groups constitute the power elite? Have these groups changed over time? Explain. 2. According to the pluralist model of power, what protects people from the abuse of power by any one group? In what ways does this work in the United States?
Please write in C++ as simple as possible I want you to create a Book Class...
Please write in C++ as simple as possible I want you to create a Book Class for a bookstore. I am not going to tell you what variables should go into it, that is for you to figure out (but you should have at least 5+). And then you must create a UML with all the variables and methods (like: the getters and setters, a default constructor, and a constructor that takes all the variables and finally the printValues() )....
Please use c++ and follow the instruction, I really want to fully understand this question and...
Please use c++ and follow the instruction, I really want to fully understand this question and I will use your code to check where I made mistake (Do not skip steps). I have written my own code which has tons of errors, and I am so confused about this lab. I need help. Lab 6.4 – C++ and Functions – Math Test Critical Review A value-returning function is a function that returns a value back to the part of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT