/* Exer02.java CIS 160 David Klick 2015-09-02 Demonstrates JOptionPane input and output Note: This program will crash if the user enters something unexpected. */ import javax.swing.JOptionPane; public class Exer02 { public static void main(String[] args) { // Declare variables double length; double width; double area; // Get length and width from user String strLength = JOptionPane.showInputDialog("Enter length of rectangle"); String strWidth = JOptionPane.showInputDialog("Enter width of rectangle"); // Turn input into numbers length = Double.parseDouble(strLength); width = Double.parseDouble(strWidth); // Calculate area area = length * width; // Display area JOptionPane.showMessageDialog(null, "The area is " + area); } }