/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package robopractice; import java.util.Scanner; /** * * @author jcmtiernan */ public class RoboPractice { /** * @param args the command line arguments */ public static void main(String[] args) { final int MAXTEAMS = 150; Integer robotTeamNumbers[] = new Integer[MAXTEAMS]; Scanner input = new Scanner(System.in); int i = 0; int j = 0; boolean isGreaterThanZero = true; Integer tempNumber = 0; System.out.println("Hello and welcome to the Robot Team Manager system."); System.out.println("We need to first get the numbers of all the robot teams to be managed."); System.out.println("Please enter multiple team numbers on one line seperated by spaces. "); System.out.println("When you have finished entering all team numbers, enter a 0 or a negative number to stop."); for (i = 0; (i < MAXTEAMS) && (isGreaterThanZero); i++ ) //do { System.out.println("Inside the for loop with i = "+i); if (input.hasNextInt()) { System.out.println("int Input has been entered"); tempNumber = input.nextInt(); } else { System.out.println("NON int Input has been entered - treat this input as a stop condition"); tempNumber = 0; } if (tempNumber > 0) { //isGreaterThanZero = true; robotTeamNumbers[i] = tempNumber; System.out.println("You entered "+robotTeamNumbers[i]+" stored at index "+i); } else { isGreaterThanZero = false; i--; } } //while(robotTeamNumbers[i-1] > 0); System.out.println("You entered a total of "+i+" pieces of data"); System.out.println("The array is size "+robotTeamNumbers.length); for (j = 0; (j < i); j++ ) { System.out.println("robotTeamNumbers["+j+"] = "+robotTeamNumbers[j]); } } }