Question: The Java Code Below Contains 6 Errors; 1. Cannot Find Symbol - Class Shape 2. Cannot Find Symbol - Class Rectangle, Square, Triangle, Circle And

The Java Code Below Contains 6 Errors; 1. Cannot Find Symbol - Class Shape 2. Cannot Find Symbol - Class Rectangle, Square, Triangle, Circle And Parallelogram After Solving The Errors Of This Code, I Want To Develop A UML Diagram For The Code. Thanks. Import Java.Util.Scanner; Public Class UpdatedAreaShapes { Private Static Scanner StdIn; Private

The java code below contains 6 errors;

1. cannot find symbol - class shape

2. cannot find symbol - class Rectangle, Square, Triangle, Circle and Parallelogram

After solving the errors of this code, I want to develop a UML diagram for the code.

Thanks.

import java.util.Scanner; public class UpdatedAreaShapes { private static Scanner stdIn; private static Shape shape; private static int attempt=0; public static void main(String[] args){ if(stdIn==null) stdIn = new Scanner(System.in); System.out.printf("Attempt "+ (++attempt) +" : Please enter your choice of shape to find the area:"); System.out.printf(" 1. Rectangle"); System.out.printf(" 2. Square"); System.out.printf(" 3. Triangle"); System.out.printf(" 4. Circle"); System.out.printf(" 5. Parallelogram"); System.out.printf(" -1. exit ");

int option = stdIn.nextInt(); if (option == 1){ System.out.printf("Enter the dimension of the rectangle "); double width = stdIn.nextDouble(); double length = stdIn.nextDouble(); shape=new Rectangle(width,length); System.out.printf("The area of the rectangle is : %.2f " , shape.getArea()); main(new String[] {}); } else if (option == 2){ System.out.print("Enter the dimension of the square "); double side = stdIn.nextDouble(); shape=new Square(side); System.out.printf("The area of the square : %.2f " , shape.getArea()); main(new String[] {}); } else if (option == 3){ System.out.print("Enter the dimension of the triangle "); double base = stdIn.nextDouble(); double height = stdIn.nextDouble(); shape=new Triangle(base,height); System.out.printf("The area of the triangle : %.2f " ,shape.getArea()); main(new String[] {}); } else if (option == 4) { System.out.print("Enter the radius of the circle "); double radius = stdIn.nextDouble(); shape=new Circle(radius); System.out.printf("The area of the circle : %.2f " , shape.getArea()); main(new String[] {}); } else if (option == 5) { System.out.print("Enter the dimension of the parallelogram "); double base = stdIn.nextDouble(); double height = stdIn.nextDouble(); shape=new Parallelogram(base,height); System.out.printf("The area of the parallelogram : %.2f " , shape.getArea()); main(new String[] {}); }else if(option==-1){ System.out.println("Exiting from Shape Area Calculator"); stdIn.close(); }else { System.out.printf("Invalid option" + " " + "Try again"); main(new String[] {}); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!