package com.javarush.task.pro.task04.task0403;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int sum = 0;
boolean isExit = false;
while (!isExit) {
System.out.println("Ваше число?");
if (s.hasNextInt()) {
int number = s.nextInt();
sum = sum + number;
} else if (s.hasNextLine()) {
String f = s.nextLine();
if (f.equalsIgnoreCase("ENTER")) {
System.out.println(sum);
isExit = true;
} else {
System.out.println("ОШИБКА");
}
}
}
}
}
package com.javarush.task.pro.task04.task0403;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int sum = 0;
boolean isExit = false;
while (!isExit) {
System.out.println("Ваше число?");
if (s.hasNextInt()) {
int number = s.nextInt();
sum = sum + number;
System.out.println(sum);
} else if (s.hasNextLine()) {
String f = s.nextLine();
String out = "ENTER";
if (f.equalsIgnoreCase(out)){
isExit = true;
} else {
System.out.println("ОШИБКА");
}
}
}
}
}