Nickolay35

Сумма.

Dec 25th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. //Программа должна посчитать сумму всех введенных чисел, и прекратить работу, когда я введу слово "сумма"
  2.  
  3. public class Solution {
  4. public static void main(String[] args) throws Exception {
  5. //напишите тут ваш код
  6. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  7. BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
  8.  
  9. double b = 0;
  10. double s = 0;
  11. while (true){
  12. String m = buffer.readLine();
  13. s = Double.parseDouble(reader.readLine());
  14. b = b + s;
  15. if (m.equals("сумма")) {
  16. System.out.println(b);
  17. break;
  18. }
  19.  
  20.  
  21.  
  22.  
  23. }
  24.  
  25. }
  26. }
Add Comment
Please, Sign In to add comment