//Created by
//Ticket Reservation System of 5 first class and 5 economy tickets
import java.util.Scanner;
public class Planeticket
{
public static void main(String args[])
{
boolean EconArray[] = new boolean[5]; // boolean array with 5 elements
boolean FirstArray[] = new boolean[5];
Scanner input = new Scanner(System.in);
int value;
for(int i =0; i < 10; i++)
{
System.out.print("Please Enter 1 for First Class or Enter 2 for Economy:");
value = input.nextInt();
if( value == (1))
{
EconArray[i] = true;
System.out.println("Your Economy ticket has been booked\n");
}
else
System.out.println("Economy is full would you like to upgrade to first class?");
if(value == (2))
{
FirstArray[i] = true;
System.out.println("Your First class ticket has been booked\n");
break;
}
}
}
}
Please dont go shredding my code to nothing. I understand there is a lot of work to be done. Right now i wish to understand why if i hit either 1 or 2 5 times i get an error. I should be able to hit 1 4 times filling the first class array leaving one empty seat and then hit 2 a couple times to fill some of those seats. As it stands after the 5 entry no matter a 1 or a 2 it calls a error. Please dont throw indepth code at me cause i wont know what it means. just why after i enter a 6th selection does it throw an error message.
Thanks in advance alonewolf23.