It works to the point that the user inputs "c" "s" or "r" then it does nothing else ? I can get it to run in my terminal window but when I try to get the JoptionPane windows to work it freezes up.
import java.util.*; // For Scanner import java.lang.String.*; // For toUpperCase() import javax.swing.JOptionPane; // for cute lil java windows public class CaculateAreaOpt { // Declare all variables needed for program public static Scanner in = new Scanner(System.in); public final static double radius = 3.14; public static char input; public static double area; public static double circumference; public static double length; public static double height; public static String str, error; public static double getArea(double x, double y) { // Char inputted by user then each case evaluates area if (input == 'C') { JOptionPane.showInputDialog( null,"Enter circumference"); circumference = in.nextDouble(); area = radius * circumference; } // end input c else if (input == 'R'){ JOptionPane.showInputDialog( null,"Enter length of rectangle"); length = in.nextDouble(); JOptionPane.showInputDialog( null,"Enter height of rectangle"); height = in.nextDouble(); area = length * height; }// end input R else if (input == 'S') { JOptionPane.showInputDialog( null, "Enter length of side"); length = in.nextDouble(); area = length * length; // end input S }// end input S // return the area return area; } /* * Method takes two double arguments */ public static void main(String[] args) { // Get User to choose what shape to calculate Area of JOptionPane.showInputDialog( null,"Calculate the Area of a Square, Rectangle or Circle-Press S for square, R for Rectangle, or C for Circle"); // String str takes Scanner in (next() value str = in.next(); /* String str is an array, so index 0 is first character * Thus index 0 is first character * Character.toUpperCase converts the String to uppercase * so you don't have to test for c, s, or r instead of C, S, R */ input = Character.toUpperCase(str.charAt(0)); /* if / else if * call the getArea() */ if (input == 'C') { getArea(radius, circumference); JOptionPane.showInputDialog( null,"The area of your circle is " + area); } // end area c else if (input == 'S') { getArea(length, length); JOptionPane.showInputDialog( null,"The area of your square is " + area); } // end area s else if (input == 'R') { getArea(length, height); JOptionPane.showInputDialog( null,"The area of your rectangle is " + area); } // end area r else { System.out.println(error); } // end error } //end main() } // end class