Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main{
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int sum;
- int num1, num2;
- boolean isNotCorrect;
- System.out.println("Снова сумма, гойда");
- num1 = 0;
- do {
- isNotCorrect = false;
- System.out.println("Введи число 1");
- try{
- num1 = Integer.parseInt(scan.nextLine());
- } catch(NumberFormatException exception) {
- isNotCorrect = true;
- System.out.println("Гойда, ошибка");
- }
- } while (isNotCorrect);
- num2 = 0;
- do {
- isNotCorrect = false;
- System.out.println("Введи число 2");
- try{
- num2 = Integer.parseInt(scan.nextLine());
- } catch(NumberFormatException exception) {
- isNotCorrect = true;
- System.out.println("Гойда, ошибка");
- }
- } while (isNotCorrect);
- sum = num1 + num2;
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement