ilikemoneygreen
Silver Member
What am I doing wrong? i cant seem to get the second dialog box to popup to enter the value. I could get it to work just in the command prompt using System.out.print but its not working out with the dialog box.
If you help me, ill give you a cyber hug. :hail:
Code:
/**Area of rectangle *//* ilikemoneygreen
* CIS163 29843
* August 24, 2012
*/
import java.util.Scanner; // scanner package
import javax.swing.JOptionPane;
public class RectangleArea {
public static void main(String[] args) {
//input the length and width
Scanner input = new Scanner(System.in);
//prompt user for length
JOptionPane.showInputDialog(null, "Enter the length : " , "Length" , JOptionPane.INFORMATION_MESSAGE);
double length = input.nextDouble();
//Prompt user for Width
JOptionPane.showInputDialog(null, "Enter the width : " , "Width" , JOptionPane.INFORMATION_MESSAGE);
double width = input.nextDouble();
//calculate area
double area = length * width;
//Display the results
System.out.println("The area of a Rectangle with a width of " + width + " and a length of " + length + " is " + area);
}
}