Scanner scan = new Scanner(System.in);
int sum = 0;
int x = scan.nextInt();
while (x != 0) {
sum += x;
x = scan.nextInt();
}
System.out.println(sum);
Объяснение:
Scanner scan = new Scanner(System.in);
int sum = 0;
int x = scan.nextInt();
while (x != 0) {
sum += x;
x = scan.nextInt();
}
System.out.println(sum);
Объяснение: