Created
March 29, 2020 07:34
-
-
Save mherman22/befc8112eddb91a6023efaca0f5d6e3c to your computer and use it in GitHub Desktop.
more understanding of java gui. #from analysis to design
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package gui; | |
| import javax.swing.*; //i am to use JOptionPane | |
| public class Rectangle { | |
| public static void main(String[] args) { | |
| // TODO Auto-generated method stub | |
| double width, length, area, perimeter; | |
| String lengthstr, widthstr, outputstr; | |
| lengthstr = JOptionPane.showInputDialog("Enter the Length:"); | |
| length = Double.parseDouble(lengthstr); | |
| widthstr = JOptionPane.showInputDialog("Enter the Width"); | |
| width = Double.parseDouble(widthstr); | |
| area = length * width; | |
| perimeter = 2 * (length + width); | |
| outputstr = "Length: "+ length + "\n" + | |
| "Width: " + width + "\n" + | |
| "Area: " + area +"square units\n" + | |
| "Perimeter"+ perimeter +"units\n"; | |
| JOptionPane.showMessageDialog(null, outputstr, | |
| "Rectangle",JOptionPane.INFORMATION_MESSAGE); | |
| System.exit(0); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment