Advertisement
dxvmxnd

Untitled

Sep 4th, 2024
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main{
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. int sum;
  8. int num1, num2;
  9. boolean isNotCorrect;
  10.  
  11.  
  12. System.out.println("Снова сумма, гойда");
  13.  
  14. num1 = 0;
  15. do {
  16. isNotCorrect = false;
  17. System.out.println("Введи число 1");
  18. try{
  19. num1 = Integer.parseInt(scan.nextLine());
  20. } catch(NumberFormatException exception) {
  21. isNotCorrect = true;
  22. System.out.println("Гойда, ошибка");
  23. }
  24. } while (isNotCorrect);
  25.  
  26. num2 = 0;
  27. do {
  28. isNotCorrect = false;
  29. System.out.println("Введи число 2");
  30. try{
  31. num2 = Integer.parseInt(scan.nextLine());
  32. } catch(NumberFormatException exception) {
  33. isNotCorrect = true;
  34. System.out.println("Гойда, ошибка");
  35. }
  36. } while (isNotCorrect);
  37.  
  38. sum = num1 + num2;
  39.  
  40. System.out.println(sum);
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement