Scanner scanner = new Scanner(System.in);
int sum = 0;
boolean done = false;
while (!done) {
String input = scanner.nextLine();
if (input.equals("ENTER")) {
done = true;
} else {
int number = Integer.parseInt(input);
sum += number;
}
}
System.out.println(sum);
}
}
Solution
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Serhiy Yurovych
8 March, 14:16
From what I see the problem is in this line:
0