this is what i have can 39 t get it to compile below the code are the instructions n 5346305

This is what I have. Can't get it to compile. Below the code are the instructions.

NOTE: This is NOT a gui program, that will be the next assignment.

class Square {

public float perimeter(float side) { return (4 * side);

String length = JOptionPane.showInputDialog(“Enter length: “);

float len = Float.parseFloat(length);

Square sq = new Square();

float circum = sq.perimeter(len);

}

}

class Circle extends Square {

public float perimeter(float radius) {

// set PI constant

final float PI = 3.14159;

return (2 * PI * radius);

}

}

class Rectangle extends Square {

public float perimeter (float side) { return ((2.0 * l) + (2.0 * w))

}

class Triangle extends Square {

public float perimeter (float side) ( return (3.0 * t)

}

public class Main

{

publicstaticvoidmain (String args[])

{

doubles, l, w, d, t;

Scanner opt = newScanner(System.in);

Scanner keyboard = newScanner(System.in);

String optionTxt = JOptionPane.showInputDialog(“This program will calculate the perimeter of different shapes.nSelect 1 for square:nSelect 2 for rectangle:nSelect 3 for circle:nSelect 4 for triangle:nSelect or 5 to exit:”);

intoptionNum = Integer.parseInt(optionTxt);

if(optionNum==1)

{

String squTxt = JOptionPane.showInputDialog(“You selected square. Please enter the length of a side in centimeters:”) ;

s=Float.parseFloat(squTxt);

JOptionPane.showMessageDialog(null,”The perimeter is: “+ (4* s) + ” cm.”);

System.exit(0);

}

if(optionNum==2)

{

String rectTxt = JOptionPane.showInputDialog(“You selected rectangle. Please enter the length of a side in centimeters:”) ;

l=Float.parseFloat(rectTxt);

String rectTxt2 = JOptionPane.showInputDialog(“Now enter the width in centimeters:”) ;

w=Float.parseFloat(rectTxt2);

JOptionPane.showMessageDialog(null,”The perimeter is: “+ ((2*l) + (2* w)) + ” cm.”);

System.exit(0);

}

if(optionNum==3)

{

String circTxt = JOptionPane.showInputDialog(“You selected circle. Please enter the diameter in centimeters:”) ;

d=Float.parseFloat(circTxt);

JOptionPane.showMessageDialog(null,”The perimeter is: “+ (Math.PI * d) + ” cm.”);

System.exit(0);

}

if(optionNum==4)

{

String triTxt = JOptionPane.showInputDialog( “You selected triangle. Please enter the length of a side in centimeters.”) ;

t=Float.parseFloat(triTxt);

JOptionPane.showMessageDialog(null, “The perimeter is: “+ (3* t) + ” cm.”);

System.exit(0);

}

if(optionNum==5)

{

JOptionPane.showMessageDialog(null, “You have chosen to exit the program. Goodbye.”);

System.exit(0);

}

else

{

JOptionPane.showMessageDialog(null, “Hey! We asked you to select from options 1-5, bub!”);

}

}

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

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now