Commit 10fba06b authored by User's avatar User

boarding pass

parent 843a989a
package airlinereservation;
import java.util.Scanner; //import scanner module
public class reservation {
public static void main(String[] args) {//main subprogram
Scanner input = new Scanner(System.in);
int choice = 0;
String reserve = "";
String plane[][] = {{"XX", "XX", "XX"}, {"XX", "XX", "06"}, {"07", "08", "09"}, //initialise the array which contains the plane seats
public static String plane[][] = {{"XX", "XX", "XX"}, {"XX", "XX", "06"}, {"07", "08", "09"}, //initialise the array which contains the plane seats
{"10", "11", "12"}, {"13", "14", "15"}, {"16", "17", "18"},
{"XX", "XX", "XX"}, {"XX", "XX", "XX"}, {"XX", "XX", "XX"},
{"28", "29", "30"}, {"31", "32", "33"}, {"34", "35", "36"},
......@@ -16,6 +11,10 @@ public class reservation {
{"XX", "XX", "XX"}, {"XX", "XX", "XX"}, {"XX", "71", "72"},
{"73", "74", "75"}, {"76", "77", "78"}, {"79", "80", "81"},
{"82", "83", "84"}, {"85", "86", "87"}, {"88", "89", "90"}};
public static void main(String[] args) {//main subprogram
Scanner input = new Scanner(System.in);
int choice = 0;
String reserve = "", section = "";
String first = "", last = "", city = "", destination = "";
System.out.println("Hello and Welcome. We first need some details-");
System.out.print("Please enter your first name: ");
......@@ -33,6 +32,7 @@ public class reservation {
+ "\nPlease Type 3 for Economy \n");
switch(choice = input.nextInt()) {//switch case to run different outcomes
case 1://case if user chooses first class/1
section = "First class";
System.out.println("You have Chosen First Class");//prints out the class that the user has chosen
boolean seat = false;
for(int p=0; p<6; p++) {
......@@ -55,7 +55,7 @@ public class reservation {
reserve = plane[s][r];
plane[s][r] = "XX";
System.out.println("Your booked seat is " + reserve);
ticket();
ticket(first,last,city,destination,section, reserve);
return;
}
}
......@@ -76,7 +76,7 @@ public class reservation {
if(reserve.equals(plane[s][r])) {
System.out.println("Seat " + reserve + " has been booked for you");
plane[s][r] = "XX";
ticket();
ticket(first,last,city,destination,section, reserve);
return;
}
}
......@@ -104,7 +104,7 @@ public class reservation {
reserve = plane[s][r];
plane[s][r] = "XX";
System.out.println("Your booked seat is " + reserve);
ticket();
ticket(first,last,city,destination,section, reserve);
return;
}
}
......@@ -202,8 +202,17 @@ public class reservation {
System.out.print("\t");
}
}
public static void ticket() {
System.out.println("END");
public static void ticket(String first, String last, String city, String destination, String section, String reserve) {
System.out.println("Here are your ticket details:"
+ "|{BOARDING PASS}|"
+ "\n Name: " + first + " " + last
+ "\n From: " + city
+ "\n To: " + destination
+ "\n Flight: "
+ "\n Seat No.: " + reserve
+ "\n Section: " + section);
System.out.println("Thanks for using our booking service");
display(plane);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment