Advertisement
therrontelford

Ending input 2

Jan 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EndingInput2 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner kb = new Scanner(System.in);
  7.         System.out.println("Enter the size of your array");
  8.         int size = kb.nextInt();
  9.         int[] nums = new int[size];
  10.         int i=0;
  11.        
  12.         while(temp>=0){
  13.             System.out.println("enter your numbers or -1 to quit");
  14.             int temp = kb.nextInt();
  15.            
  16.             if(temp >=0){
  17.                 nums[i]=temp;
  18.                 i++;
  19.            
  20.         }
  21.     }      
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement