I know this is a very common program that has been discussed, and I have searched through all the previous posts about it but still having problems. It's a program for an airline seating reservation. Consists of 12 seats total, 1-4 is First Class, and 5-12 is Economy. I have to use a two dimensional array to simulate the seats. I am having trouble with the loop and also on how to work in a boolean expression into the program. I am a beginner to java. Here is what I have so far:
import java.util.Scanner;
public class flight{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
boolean seat[][];
seat = new boolean[6][2];
int value;
value = 1;
while(value != 0)
System.out.print("Please type 1 for First Class or type 2 for Economy or type 0 to end the program.");
value = input.nextInt();
switch (value){
case 1:
for (int i = 0; i < 2; i++)
{
for (int j = 0; j <2; j++)
if(i<2 & j<2)
System.out.println("Your seat is: " + 2*i + (j+i));
}
else {
System.out.println();
System.out.print("There are no more seats available in the selected class");
}
break;
case 2:
for (int i = 2; i < 6; i++)
{
for (int j = 2; j <6; j++)
if(i<6 & j<6)
System.out.println("Your seat is " + 2*i + (j+i));
}
else {
System.out.println();
System.out.print("There are no more seats available in the selected class");
}
break;
case 0:
break;
default:
System.out.println("Invalid selection, please try again..!");
}
}
}