package class3_2_Gui; // Josiah Yoder, MSOE, 21 September 2015 import javax.swing.*; import java.util.Scanner; public class CircleDecisionsGui { public static void main(String[] args) { // GUI: TO be continued... //final double PI = 3.141592; Scanner in = new Scanner(System.in); String radiusStr = JOptionPane.showInputDialog(null, "Please enter the radius of a circle"); double radius = Double.parseDouble(radiusStr); String line = JOptionPane.showInputDialog(null, "What do you want to do?\n"+ "To compute the area of the circle, enter \"a\".\n" + "Or, enter \"c\" for circumference: "); char c = line.charAt(0); if(c=='a') { double area = Math.PI * radius * radius; JOptionPane.showMessageDialog(null, "The area is: " + area); } else if(c=='c') { double circumference = 2 * Math.PI * radius; JOptionPane.showMessageDialog(null, "The circumference is: " + circumference); } else { JOptionPane.showMessageDialog(null, "Unexpected command: " + c + " Please enter \"c\" or \"a\" next time."); } JOptionPane.showMessageDialog(null, "Thank you for using this program."); } }