ya_zay4eg

level05.lesson12.home05

Nov 24th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package com.javarush.test.level05.lesson12.home05;
  2.  
  3. /* Вводить с клавиатуры числа и считать их сумму
  4. Вводить с клавиатуры числа и считать их сумму, пока пользователь не введёт слово «сумма». Вывести на экран полученную сумму.
  5. */
  6.  
  7. import javax.swing.plaf.basic.BasicButtonUI;
  8. import java.io.BufferedReader;
  9. import java.io.InputStreamReader;
  10.  
  11. public class Solution
  12. {
  13.     public static void main(String[] args) throws Exception
  14.     {
  15.         BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
  16.         int result = 0;
  17.         while (true) {
  18.             String vvod = reader.readLine();
  19.  
  20.             if (vvod.equals("сумма")) {
  21.                 System.out.println(result);
  22.                 return;
  23.             }
  24.             int cifra=Integer.parseInt(vvod);
  25.             result=result+cifra;
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment