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

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++! 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 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...
I want to understand how this can be solved in c++. Please send a screenshot also...
I want to understand how this can be solved in c++. Please send a screenshot also with your code so I can see how it is supposed to be formatted or indented. Instructions: Your program will read in a file of commands. There are three types of commands: Warrior creates a new warrior with the specified name and strength. Battle causes a battle to occur between two warriors. Status lists all warriors, alive or dead, and their strengths. A sample...
You cna hand write this if you want, Please code this in C Thank you PROBLEM...
You cna hand write this if you want, Please code this in C Thank you PROBLEM DESCRIPTION: Write a program to implement the following requirement: The program will read from standard input two things - a string str1 on the first line of stdin (this string may be an empty string) - a string str2 on the second line of stdin (this string may be an empty string) Note that stdin does not end with '\n'. The program will output...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT