Create a java program based on the geometric shapes example


* Create a Java program based on the geometric shapes example described at the beginning of this lesson using Classes Square, Triangle, Rectangle, and Circle to help describe inheritance and polymorphism using the circumference() method. The program will calculate the circumference of a designated shape.
* The program should begin by prompting you for the shape you want to calculate the circumference for - square, rectangle, circle, or triangle. You can designate 1-square, 2-rectangle, 3-circle, 4-triangle, and 5-Exit.
* Once you select your shape, then the program should prompt you for enough information to calculate the circumference of the chosen shape. For example, if you select square then the program should prompt you for the length of one side of the square. If you select circle, then the program will prompt you for either the radius or diameter of the circle. With the information for calculating the circumference, have the program complete the calculation and print the information to the screen, using one of the JOptionPane output classes (methods) or any other graphical output method.

Your output should look something like this:

* You selected Square
Length of each side=XX.X cm (centimeters -- do all measurements in metric)
Area=XX.X cm
o Make sure you create the program in a loop and have the program prompt you for another shape and calculation. Enter 5 for exit.
o You should first create a Square superclass, and then from it create Rectangle, Circle, and Triangle subclasses. In the Square class create a circumference() method (e.g., circumf()) and then re-define that method in each subclass to calculate the area of the appropriate shape.
o You should also create a color() method (e.g., color()) and have the Square superclass return the color as white. Have each subclass also return color, but redefine the color method in the Circle subclass to return the color as blue.
o Also, you should now be using the JOptionPane.showMessageDialog() method for displaying your output instead of System.out.println().

Note: Make sure you create a float constant for the value of

pi=3.14159

in your Circle class. 

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Create a java program based on the geometric shapes example
Reference No:- TGS0129475

Expected delivery within 24 Hours