Java Assignment. Help me, please. What am I doing wrong? I can't get the expected output correct. Example #1 If, the inp

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Java Assignment. Help me, please. What am I doing wrong? I can't get the expected output correct. Example #1 If, the inp

Post by answerhappygod »

Java Assignment. Help me, please. What am I doing
wrong? I can't get the expected output
correct.
Example #1 If, the input is:
Enter Course Length : 20
Enter Course Width : 10
Expected Output is:
Total square yards of rough sod : 152
Total square yards of smooth sod : 44
Tons of sand : 4
Number of bushes : 58
Example #2 If, input is:
Enter Course Length : 20
Enter Course Width : 20
Expected Output is:
Total square yards of rough sod : 206
Total square yards of smooth sod : 175
Tons of sand : 15
Number of bushes : 78
The
output MUST be exactly as I
stated.
Problem Description and Given Info
Gene's Green Golf Center is remodeling their golf course, and
has hired you to help write a program that will be used to
determine what materials will be needed to complete the project.
There are 18 holes on the golf course, but Gene likes to keep
things simple, so every hole looks very similar. A typical Hole at
Gene's Green Golf Center looks like the image below - only the
length and width change.
Java Assignment Help Me Please What Am I Doing Wrong I Can T Get The Expected Output Correct Example 1 If The Inp 1
Java Assignment Help Me Please What Am I Doing Wrong I Can T Get The Expected Output Correct Example 1 If The Inp 1 (47.61 KiB) Viewed 108 times
Given the length and width of a hole (in yards), Gene needs to
know the following:
The program should take, as inputs from the user, the length and
the width of a hole (both in yards). The program should then
perform all necessary calculations and produce a tidy report with
all of the required information regarding materials needed to
construct the hole.
Other Details
Part 9 - Full Program
Design and construct a complete program for Gene's Green. Use
the methods that you created in the previous Individual
Assignments.
Additional Methods
You may also find it helpful to design and write some additional
methods to do each of the following:
Each of the methods described in the list above could call one
or more of the methods you already wrote
(e.g. areaOfRectangle, areaOfCircle, etc.) as helper
methods to compute some needed values.
You will also need to implement the code necessary to collect
and store the program inputs. Then you will need to implement the
code that will call your methods to compute all the required
program outputs. Finally, you will need to implement the code to
print out a nicely formatted report with all of the information
that Gene needs.
Here are some examples of what Gene should see when he runs your
program.
Make sure that your program collects the two required inputs in
this order:
Helpful Hints:
This is the code I wrote, but it's NOT giving me
the expected output:
import java.util.Scanner;
public class GenesGreen {
public static void main(String[] args) {
// declare and create your Scanner
Scanner scnr = new Scanner(System.in);
double length, width;

// prompt for and collect the required
inputs
System.out.print("Enter Course Length :
");
length = scnr.nextDouble();

System.out.print("Enter Course Width :
");
width = scnr.nextDouble();

scnr.close();
System.out.println();

// call your methods to compute the required
outputs
double sandTrapDiameter = width / 4;
double teeDiameter = width / 3;
double puttingGreenDiameter = (2 * width) /
3;

double teeArea =
areaOfCircle(teeDiameter);
double puttingGreenArea =
areaOfCircle(puttingGreenDiameter);
double sandTrapArea =
areaOfCircle(sandTrapDiameter);

double smoothSodArea = Math.ceil(teeArea +
puttingGreenArea);

double roughSodArea =
Math.ceil(areaOfRectangle(width, length) - teeArea -
puttingGreenArea - sandTrapArea);

sandTrapDiameter = sandTrapDiameter * 4;

double sandTons =
Math.ceil((areaOfCircle(sandTrapDiameter * 1) * 80.0) /
2000.0);


// display the results
System.out.println("\nTotal square yards of
rough sod : " + (int)roughSodArea);
System.out.println("Total square yards of
smooth sod : " + (int)smoothSodArea);
System.out.println("Tons of sand
: " +
(int)sandTons);
System.out.println("Number of bushes
: " +
(int)(perimeterOfRectangle(width, length) - 2 ));

}

// copy your method definitions from the previous
parts here below
public static double areaOfRectangle(double width,
double height) {
double area = width * height;

return area;
}

public static double areaOfCircle (double diameter)
{
double area = 3.1415/4 * (diameter *
diameter);
return area;
}

public static double perimeterOfRectangle(double
width, double height) {
double perimeter = 2 * (width +
height);
return perimeter;
}

public static double perimeterOfCircle(double
diameter) {
double perimeter = 3.1415 *
diameter;
return perimeter;
}
// add any additional methods you may want here below
below
public static double sandTrapArea(double
width){
double sandTrapDiameter = width /
3;
return
areaOfCircle(sandTrapDiameter);
}

}
Thanks!
Exit Trail Width Brick Retaining Wall Bushes 00 000000000 Putting Green Sand Trap Rough Sod Smooth Sod Length ne Smooth Sod Tee Entry Trail
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply