Advertisement
Sinux1

PS7Q1

Oct 20th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.util.*;
  2. class Q1
  3. {
  4.  
  5.     public static void main(String[] args)
  6.     {
  7.         ArrayList<Integer> intList = new ArrayList<Integer>();
  8.        
  9.         Scanner kb = new Scanner(System.in);
  10.         int userInput;
  11.         do
  12.         {
  13.             System.out.println("Enter an integer (0 to exit)");
  14.             userInput = kb.nextInt();
  15.             if(userInput != 0)
  16.                 intList.add(userInput);
  17.            
  18.         }while(userInput != 0);
  19.        
  20.         System.out.println("Got it.  You entered:");
  21.         for(Integer num : intList )
  22.             System.out.println(num);
  23.         kb.close();
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement