Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- public class StartClass {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- String value;
- double width, length, area;
- boolean repeat = false;
- do {
- try {
- value = JOptionPane.showInputDialog("Enter length rate: ");
- length = Double.parseDouble(value);
- value = JOptionPane.showInputDialog("Enter width: ");
- width = Double.parseDouble(value);
- area = length * width;
- JOptionPane.showMessageDialog(null, "Area is : " + area);
- repeat = false;
- } catch (NumberFormatException e) {
- JOptionPane.showMessageDialog(null, "Error! Enter numeric value only!", "Data input Error", JOptionPane.ERROR_MESSAGE);
- repeat = true;
- }
- } while (repeat);
- input.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement