import java.util.Scanner;
public class CalculateTest {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int total = 0;
while (true) {
System.out.print("Input any number : ");
if (scanner.hasNextInt()) {
int number = scanner.nextInt();
total += number;
} else {
System.out.println("Incorrect input: an integer is required");
scanner.next();
continue;
}
System.out.print("Input again? (yes/no) : ");
String line = scanner.next();
if ("yes".equals(line)) {
continue;
// yes 문자열이 아닌 경우에는 모두 no로 처리
} else {
break;
}
}
System.out.println("The total from the input is : " + total);
}
}