Advertisement
Guest User

Labor 2 Mirza Muratovic

a guest
Apr 2nd, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. package proba;
  2.  
  3. import java.util.Scanner;
  4.  
  5. import javax.swing.Spring;
  6.  
  7. public class main {
  8.        
  9.         public static void main(String args[])
  10.         {
  11.            
  12.                 int integers = 0, sum=0;
  13.                 Scanner userInput = new Scanner(System.in);
  14.                
  15.                 System.out.print("Enter a  integers: ");
  16.                
  17.                
  18.                 while(true)
  19.                 {
  20.                    if(userInput.hasNextInt()) {
  21.                        integers=userInput.nextInt();
  22.                        sum+=integers;
  23.                    }
  24.                    else if(userInput.hasNext("KRAJ")) {
  25.                        break;
  26.                    }
  27.                    
  28.                 }
  29.  
  30.                 userInput.close();
  31.                 System.out.println("Sum is: " + sum);
  32.  
  33.             }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement