I'm newbie in Java and my problem is the output of my code will loop to infinity. First, I was asked to initialize the number of tickets to sum of number of children and number of adults.
int noOfChildren = 2;
int noOfAdults = 5;
int noOfTicket = noOfChildren + noOfAdults;
travelID = new int[noOfTicket];
for(int i = 0; i < travelID.length; i++)
travelID[i] = i + 1;
int i = 0;
System.out.println("ID " + travelID[i] + ":" + travelID[i] );
while (i < noOfTicket);
You need to increment
i inside the
do while loop. The
for loop has
do while loop needs something like that.