Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String firtstName = enterName("First");
- String secondName = enterName("Second");
- JOptionPane.showMessageDialog(null, String.format("%s + %s = <Въведи нещо>", firtstName, secondName));
- }
- private static String enterName(String type) {
- String name = "";
- boolean isCorrect = false;
- while (!isCorrect) {
- try {
- name = JOptionPane.showInputDialog(null, "Enter " + type + " Name");
- Double.parseDouble(name);
- JOptionPane.showMessageDialog(null, "Try Again");
- } catch (Exception igonred) {
- JOptionPane.showMessageDialog(null, "Correct - " + name);
- isCorrect = true;
- }
- }
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment