Simple beginner program!

I'm doing this program on Mindtap and the website keeps giving me a score 50%. The question is:
"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."
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream> 
#include <iomanip>

using namespace std;

// constant for PI

int main()
{
     
    // variable declaration(s) length;
double length;
double space;
int totalspace;
double radius;
int trees;
    // accept user input
cout << "Enter the length of the Yard:" << endl;
    cin >> length;
cout << "Enter the radius of a fully grown tree:" << endl;
    cin >> radius;
cout << "Enter the space between fully grown trees:" << endl;  
    cin >> space;
    // program logic
trees = (length*length)/(radius*radius*3.14159+space);
totalspace = (radius*radius*3.14159)*trees;
    // output statement(s)
cout << "The number of trees can be planted is:" << trees << endl;
cout << "The total space that will be occupied  is:" << totalspace << endl;
    return 0;
}
Look at your calculation at line 25.
Why are you squaring length?
Why are you computing the area of a tree?
Why are you adding the space between trees (feet) to the area (square feet)?
1. I'm multiplying the length by itself to get the area of the yard, supposed the yard is a square or a rectangle which is why i'm confused.
2. Next, i divided the area of the yard by the tree's area to get the number of trees that can be planted in the yard.
3. i'm lost there.
The question is not clear enough for me to do it.
Paula and Danny want to plant evergreen trees along the back side of their yard.

You're not calculating trees to fill the whole area of the yard. You're calculating a single row of trees, along one side of the yard. You should be working in one dimension, not two.
Topic archived. No new replies allowed.