knugi

Untitled

Jun 30th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. package zajęcia2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Zad4 {
  6.  
  7. public static void main(String[] args) {
  8. Scanner wej = new Scanner(System.in);
  9. int suma = 0;
  10. int wejs;
  11. while(true){
  12. if(wej.hasNextInt()){
  13. wejs = wej.nextInt();
  14. if(wejs==0){
  15. break;
  16. }
  17. suma+=wejs;
  18. continue;
  19. }
  20. else{ System.out.println("To musi być liczba!"); wej.next(); continue;}
  21. }
  22. System.out.println("Suma podanych liczb:" +suma);
  23. wej.close();
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment