-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSum.java
More file actions
26 lines (23 loc) · 812 Bytes
/
Sum.java
File metadata and controls
26 lines (23 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Консоль-копилка
Вводить с клавиатуры числа и считать их сумму, пока пользователь не введет слово "сумма".
Вывести на экран полученную сумму.
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
int sum = 0;
while (true) {
String s = buffer.readLine();
if (s.equals("сумма")) {
System.out.println(sum);
break;
}
else {
sum += Integer.parseInt(s);
}
}
}
}