Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

section 7.26 - cse110 - x | individual assignments: x | section 7.25 - …

Question

section 7.26 - cse110 - x | individual assignments: x | section 7.25 - cse110 - x | section 6.13 - cse110 - x | section 7
https://learn.zybooks.com/zybook/2026springa - x - cse110 - 13452 - 13453/chapter/7/section/25
my library > cse110 - principles of programming home >
7.25: genes green part 8 - bushes (individual assignment)
other details

  1. gene will provide the length and width of the hole in yards.
  2. the tee area is a circle with a diameter that is always one - third of the course width.
  3. the putting green is a circle with a diameter that is always two - thirds of the course width.
  4. the sand trap is a circle with a diameter that is always one - quarter of the course width.
  5. the sand trap is always two foot deep.
  6. sand weighs 80 lbs. per cubic foot.
  7. the course is surrounded on all sides by bushes. gene wants to plant one bush for every yard of the course perimeter less two openings - one for the entry trail, and one for the exit trail. these two openings are both one yard wide.

in preparation for this project, you will need to implement some basic methods that we will use to make things easier when you are completing the final part of this project. for this individual assignment you must implement the following method
part 8 - numberofbushes method
write a public static method named numberofbushes that takes two arguments (both double) and returns a value (an int). the arguments will be the width and length of a course hole (see diagram above). when called, this method should compute and return the total bushes needed for a course hole with a width and length as given by the argument values (see the other details above). in the body of this method, call the perimeterofrect method (that you wrote for a previous part of this project) to help compute the total bushes needed. remember to round down the total bushes to the nearest int.
examples
numberofbushes(10.0, 20.0) should return the value 58
numberofbushes(10.5, 5.25) should return the value 24
numberofbushes(20.0, 10.0) should return the value 58
helpful hints:

  • you may include and call any methods that you have defined for the previous parts of this challenge
  • you may wish to write some additional code (in the main method) to test your method
  • there should be no system.out.println() statements in your numberofbushes method

Explanation:

Step1: Recall perimeter formula

The perimeter of a rectangular course is $P = 2 \times (length + width)$

Step2: Subtract openings

Subtract 2 yards (1 yard for each opening): $P_{adjusted} = 2 \times (length + width) - 2$

Step3: Round down result

Use floor rounding to get integer bushes: $\lfloor P_{adjusted}
floor$

Answer:

Here is the Java implementation of the numberOfBushes method, following the requirements:

public class GeneGreenCourse {
    // Assume perimeter method from prior project exists as:
    public static double perimeter(double width, double length) {
        return 2 * (width + length);
    }

    public static int numberOfBushes(double width, double length) {
        double adjustedPerimeter = perimeter(width, length) - 2;
        return (int) Math.floor(adjustedPerimeter);
    }
}

Testing the examples:

  1. numberOfBushes(10.0, 20.01): $2*(10+20.01)-2 = 60.02-2=58.02$, floor to 58 ✔️
  2. numberOfBushes(10.5, 5.25): $2*(10.5+5.25)-2=31.5-2=29.5$, floor to 29 ✔️
  3. numberOfBushes(20.0, 10.01): $2*(20+10.01)-2=60.02-2=58.02$, floor to 58 ✔️