These are the instructions:

Write a program to allow the user to calculate the area and perimeter of a square, or the area and circumference of a circle, or the area of a triangle.

To do this, the user will enter one of the following characters: S, C, or T. The program should then ask the user for the appropriate information in order to make the calculation, and should display the results of the calculation.

Use a while loop to allow the user to get multiple calculations of results. Ask the user to enter a Q to indicate that he or she wishes to quit.

See the example program execution shown in class.

Only display your name once.

The program should use dialog boxes.

When expecting an S, C, T, or Q the program should reject other characters with an appropriate message.

Get extra points for allowing both the uppercase and lowercase versions of a valid character to work.

Here is what I have so far

import javax.swing.JOptionPane;

public class ShapesCalcLoop {

public static void main(String[] args) {

//Prompt the user to Enter S, C, T, or Q to quit

char shape = JOptionPane.showInputDialog("Enter S, C, T, or Q to quit: ").charAt(0);

switch(shape) {

while (shape != 'Q'){

case 's':;

case 'S': {

String lengthString = JOptionPane.showInputDialog("Enter length of side: ");

double length = Double.parseDouble(lengthString);

//Calculate perimeter and area of square

double perimeter= ( 4 * length);

double area=(length*length);

String output = "Perimeter is equal to: " + perimeter + "\n" + "Area is equal to: " + area;

JOptionPane.showMessageDialog(null,output);

}; break;

case 'c':;

case 'C': {

String radiusString = JOptionPane.showInputDialog("Enter radius: ");

double radius = Double.parseDouble(radiusString);

//Calculate circumference and area of circle

double circumference= (2*3.14*radius);

double area = (Math.PI * (radius * radius));

String output2 ="Circumference is equal to: " + circumference + "\n" + "Area is equal to: " + area;

JOptionPane.showMessageDialog(null,output2);

}; break;

case 't':;

case 'T': {

String baseString = JOptionPane.showInputDialog("Enter length of base: ");

double base = Double.parseDouble(baseString);

String heightString = JOptionPane.showInputDialog("Enter height of triange: ");

double height = Double.parseDouble(heightString);

//Calculate area of triangle

double area = (base * height) / 2;

String output3 = "Area is equal to: " + area;

JOptionPane.showMessageDialog(null,output3);

}; break;

default: {

JOptionPane.showMessageDialog(null,"Incorrect variable please enter S,C, or T only");

System.exit(1);

}

};

}

JOptionPane.showMessageDialog(null,"This program was written by Justeena Leonard");

}

}