Advertisement
bobo_bobkata

Untitled

Jun 1st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class a {
  4.  
  5.     public static void main(String[] args) {
  6.         String firtstName = enterName();
  7.         String secondName = enterName();
  8.         JOptionPane.showMessageDialog(null, firtstName + System.lineSeparator() + secondName);
  9.     }
  10.  
  11.     private static String enterName() {
  12.         String name = "";
  13.         boolean isCorrect = false;
  14.         while (!isCorrect) {
  15.             try {
  16.                 name = JOptionPane.showInputDialog(null, "Enter Name");
  17.                 Double.parseDouble(name);
  18.                 JOptionPane.showMessageDialog(null, "Enter Name Again");
  19.             } catch (Exception igonred) {
  20.                 JOptionPane.showMessageDialog(null, "Correnct - " + name);
  21.                 isCorrect = true;
  22.             }
  23.         }
  24.         return name;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement