Advertisement
wicus3x

Pętla While

Dec 11th, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1.  
  2. package javaapplication14;
  3.  
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class JavaApplication14 {
  8.  
  9.    
  10.     public static void main(String[] args) {
  11.         Scanner input = new Scanner(System.in);
  12.        
  13.          int a=0;
  14.          int b=0;
  15.          System.out.print("Podaj liczbę (mniejsza od zera, wyłączy program) \n");
  16.          while(a>=0){
  17.            
  18.             a = input.nextInt();
  19.              b+=a;
  20.          }
  21.          System.out.println("Suma liczb, które wpisałeś to :  "+b);
  22.     }
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement