Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Aftached FilosGoomotry java (2 235 KB) The attached prograa is your stasting poi

ID: 3737492 • Letter: A

Question

Aftached FilosGoomotry java (2 235 KB) The attached prograa is your stasting point for this assigament. The Geometry java prograas will compile, but when you sua it, it doesn't appear to do anything except wait. That is because it is waiting for user inpet, but the user doesn't have the menu to choose from yet. You will need to create one per the following 1. Above the main method, but in the Geometry class, create a statie method called printMenn that has no parameter list and does aot retura a value. It will simply print out instructions for the user with a meu of options for the user to cboose from. The menu sbould appear to the user as: This isa geometry calculator, Choose what you would like to calculate . Find the area of a rectangle 2. Find the perimeter of a rectangle 3. Find the perimeter of a triangle Enter the member of your choice 1 Add a line in the main method that calls the printMenu method as indicated by the coaments 2. Compile, debug, and nn. You should be able to choose any option, but you will always get O for the answer, we will fix this n the next task. 3. Write a static method called rectangleArea that takes in the length and width of the rectangle and retums the area using the forla A r (ie. Length widhh Write a static method called rectanglePerimeter that takes in the leugth and the width of the rectaugle and returns the perimeter of the rectaagle using the fomula P-21+2w Write a static method called trianglePerimeter that takes in the lengths of the three sides of the triangle and returns the perimeter of the triangle which is calculated by adding up the three sides. 6 Add lines in the main method in the Geometry class which will call these methods. The comments indicate wbere to place the method calls

Explanation / Answer

import java.util.Scanner; public class Geometry { public static void main(String[] args) { int choice; char letter; double value, radius, length, width, height, base, side1, side2, side3; Scanner keyboard = new Scanner(System.in); letter = 'N'; while(letter != 'Y' && letter != 'y') { System.out.println("1. Area of rectangle"); System.out.println("2. Perimeter of rectangle"); System.out.println("3. Perimeter of traingle"); System.out.print("Enter your choice : "); choice = keyboard.nextInt(); value = 0.0; switch(choice) { case 1: System.out.print("Enter the length of the rectangle: "); length = keyboard.nextDouble(); System.out.print("Enter the width of the rectangle: "); width = keyboard.nextDouble(); value = rectangleArea(length, width); System.out.println("The area of the rectangle is " + value); break; case 2: System.out.print("Enter the length of the rectangle: "); length = keyboard.nextDouble(); System.out.print("Enter the width of the rectangle: "); width = keyboard.nextDouble(); value = rectanglePerimeter(length, width); System.out.println("The perimeter of the rectangle is " + value); break; case 3: System.out.print("Enter side 1 of the triangle : "); side1 = keyboard.nextDouble(); System.out.print("Enter side 2 of the triangle : "); side2 = keyboard.nextDouble(); System.out.print("Enter side 3 of the triangle : "); side3 = keyboard.nextDouble(); value = trainglePerimeter(side1, side2, side3); System.out.println("The perimeter of the triangle is " + value); break; default: System.out.println("You did not enter a valid choice."); } keyboard.nextLine(); System.out.print("Do you want to exit the program (Y/N) : "); letter = keyboard.next().charAt(0); } } private static double trainglePerimeter(double side1, double side2, double side3) { return side1 + side2 + side3; } private static double rectanglePerimeter(double length, double width) { return 2 * (length + width); } private static double rectangleArea(double length, double width) { return length * width; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote