Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find out why the code has errors 4 TestRectangle.java X Source History 1 2 import java.util.Scanner; /* 23456M /** * 21 22222 23 24 25

Find out why the code has errors

imageimage

4 TestRectangle.java X Source History 1 2 import java.util.Scanner; /* 23456M /** * 21 22222 23 24 25 27 28 29 30 31 32 33 34 35 36 * @author summers */ public class TestRectangle { public static void displayMenu() { 7 8 9 10 11 12 13 14 15 16 } 17 18 - 19 System.out.println("1. Set length"); System.out.println("2. Set width"); System.out.println("3. Calculate Area"); System.out.println("4. Calculate Perimeter"); System.out.println("5. Exit"); public static void main(String[] args) { Scanner input = new Scanner(System.in); Rectangle rect = new Rectangle(); try { int choice = 0; while (choice != 5) { System.out.println("Enter your choice (1-5):"); choice = input.nextInt(); switch (choice) { case 1: System.out.println("Enter length: "); double length = input.nextDouble(); rect.setLength (length); break; case 2: System.out.println("Enter width: "); double width = input.nextDouble(); rect.setWidth(width); break; 37 case 3: 38 System.out.println("Length 39 40 System.out.println("Width || = || = + rect.getLength()); +rect.getWidth()); System.out.println("Area = + rect.area()); 41 break; 42 case 4: 43 44 45 46 47 case 5: 48 System.out.println("Length System.out.println("Width || = + rect.getLength()); || = + rect.getWidth()); || System.out.println("Perimeter = + rect.perimeter()); break; System.exit(0); 49 >

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions