So i tried making a simple java reservation system but the problem is that the scanner functions won't work so the program is not taking any inputs. I tried putting the scanners but it shows me an warning about the local variables not being used when i tried to run the program and hence the scanners aren't working so the whole program is stuck on the input part and not doing anything else. Im pretty new to java and is trying to learn by creating projects so i will appreciate any help and advices thank you. Here is the code: So the part or line of code that shows a warning local variable not being used are lines 8,9,16,34,36,46,48 so far those are the only problems that are showing as well as the input or the scanners not working when i run the program.
package random.java;
import java.util.Scanner;
public class AirlineReservation {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int planeclass[] = new int[10];
boolean available = false;
boolean y=true;
int number = 0, Premium = 1, Regular = 6;
String x = null;
while(Premium<=5&&Regular<=10)
{
System.out.print("Enter 1 for Premium class or 2 for Regular or -1 to exit");
Scanner in1 = new Scanner(System.in);
if(number == -1);
break;
}
if(number == 1 && Premium <= 5) {
System.out.println("You are assigned to First class\t"+"Seat#" + Premium);
Premium++;
}
else if(number == 2 && Regular <=10) {
System.out.println("You are assigned to Regular class\t" + Regular);
Regular++;
}
else if(number == 1 && Premium >= 5) {
System.out.println("First class full"+" ");
if(Regular <= 10) {
System.out.println("Is it acceptable to be placed in the Regular class");
Scanner in1 = new Scanner(System.in);
in.close();
if(x.equals("y")) {
System.out.print("Seat Reserved in Regular class\t" + Regular);
}
else {
System.out.println("Next Flight leaves in 3 hours.\t");
}
}
else if(number == 2 && Regular == 10) {
System.out.println("Regular class full\t");
Scanner in1 = new Scanner(System.in);
in.close();
if(x.equals("y")) {
System.out.println("You are assigned to Premium\t" + Premium);
}
else if (Premium == 5 && Regular == 10) {
System.out.println("Plane is full, next flight is in 3");
}
else {
System.out.println("Next flight leaves in 3 hours\t");
}
for(int i=1; i<planeclass.length; i++) {
System.out.println(planeclass[Premium] + planeclass[Regular]);
}
}
}
}
}