This is my code for a school assignment, and I don't understand where I am making a mistake. The code has some extra lines for things that have not yet been implemented but They shouldn't cause any problems or errors. I am really stuck, and any ideas as to what i am doing wrong are very much appreciated. Even if I have to rewrite a majority of what I have already written I am ok with trying out any suggestions.
(USEING ECLIPSE TO WRITE THE CODE)
Menu class:
import java.util.Scanner;
public class Menu {
static double bal = 0;
public double Bal() {
//bal = bal + ticketCost;
return bal;
}
/////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
Plane callPlane = new Plane();
Ticket callTicket = new Ticket();
Scanner input = new Scanner(System.in);
Scanner input2 = new Scanner(System.in);
Scanner input3 = new Scanner(System.in);
//Scanner input4 = new Scanner(System.in);
System.out.println("Air Canada\n");
//Menu tabs
System.out.println("Please chose which option you would like.\n");
System.out.println("Purchase a Ticket");
System.out.println("Ticket Pricing");
System.out.println("Availability");
System.out.println("Checkout");
System.out.println("Get a refund\n");
///////////
String menuChoice = input.nextLine();
menuChoice = menuChoice.toLowerCase();
if (menuChoice.equals("purchase a ticket")) {
input.close();
System.out.println("Would you like to purchase a Business Class seat or an Economy Class seat?");
String choice2 = input2.nextLine();
choice2 = choice2.toLowerCase();
int x = 0;
if (choice2.equals("business class")) {
input2.close();
System.out.println("How many seats would you like to purchase?");
int choice3 = input3.nextInt();
input3.close();
do {
callPlane.businessClass();
x += 1;
}while(x != choice3);
}else {
System.out.println("How many seats would you like to purchase?");
int choice3 = input3.nextInt();
input3.close();
do {
callPlane.economyClass();
x += 1;
}while(x != choice3);
}
////////////
}else if (menuChoice.equals("ticket pricing")) {
input.close();
System.out.println("Would you like to purchase a Business Class seat or an Economy Class seat?");
String choice2 = input2.nextLine();
choice2 = choice2.toLowerCase();
if (choice2.equals("business class")) {
input2.close();
callTicket.busPrice();
}else {
callTicket.ecoPrice();
}
}else if (menuChoice.equals("availability")) {
input.close();
}else if (menuChoice.equals("checkout")) {
input.close();
}else if (menuChoice.equals("get a refund")) {
input.close();
if (bal <= 0) {
System.out.println("You have no purchased tickets to refund");
}
}
}
/////////////////////////////////////////////////////////////////////////////////
}
Plane Class:
import java.util.ArrayList;
import java.util.Scanner;
/////////////////////////////////////////////////////////////////////////////////
public class Plane {
Ticket callTicket = new Ticket();
/////////////////////////////////////////////////////////////////////////////////
public void businessClass() {
Scanner input = new Scanner(System.in);
boolean seat[][] = new boolean[2][3];
for (int row = 0; row < seat.length; row++) {
for (int col = 0; col < seat[row].length; col++) {
if (!seat[0][col]) {
seat[0][col] = true;
System.out.println("You have place number 0" + col + " in the Business Class");
break;
}
}
if (seat[0][2]) {
if (seat[1][2]) {
System.out.println("The plane is full, welcome again");
System.exit(0);
} else {
System.out.println("Business Class is full, do you want to book in the Economy Class? (yes or no)");
String choice = input.nextLine();
choice = choice.toLowerCase();
if (choice.equals("yes")) {
economyClass();
} else {
System.out.println("Thank you and welcome again");
System.exit(0);
}
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////
public void economyClass() {
Scanner input = new Scanner(System.in);
boolean seat[][] = new boolean[2][3];
for (int row = 0; row < seat.length; row++) {
for (int col = 0; col < seat[row].length; col++) {
if (!seat[0][col]) {
seat[0][col] = true;
System.out.println("You have place number 0" + col + " in the Economy Class");
break;
}
}
if (seat[0][2]) {
if (seat[1][2]) {
System.out.println("The plane is full, welcome again");
System.exit(0);
} else {
System.out.println("Economy Class is full, do you want to book in the Business Class? (yes or no)");
String choice = input.nextLine();
choice = choice.toLowerCase();
if (choice.equals("yes")) {
businessClass();
} else {
System.out.println("Thank you and welcome again");
System.exit(0);
}
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////
}
Ticket class:
import java.util.Scanner;
public class Ticket {
Plane callPlane = new Plane();
/////////////////////////////////////////////////////////////////////////////////
public void busPrice() {
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of Business Class seats you would like to purchase");
int numSeats = input.nextInt();
double price = (numSeats * 200) * 1.13;
System.out.println("The price of " + numSeats + "Business Class seats is: " + price);
}
/////////////////////////////////////////////////////////////////////////////////
public void ecoPrice() {
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of Economy Class seats you would like to purchase");
int numSeats = input.nextInt();
double price = (numSeats * 115) * 1.13;
System.out.println("The price of " + numSeats + "Economy Class seats is: " + price);
}
/////////////////////////////////////////////////////////////////////////////////
}
error message:
Screen Shot 2019-01-15 at 7.11.30 PM.jpg