Code:
import java.util.*;
public class mainmenu {
public static void main(String[] args) {
displayMenu();
}
public static void displayMenu()
{
System.out.println("*****************************************************");
System.out.println("* FERRY TICKETING SYSTEM *");
System.out.println("* MAIN MENU *");
System.out.println("* Select P for Purchase Ticket *");
System.out.println("* Select V to View Seating Arrangement *");
System.out.println("* Select Q to Quit the system *");
System.out.println("*****************************************************");
int[] anArr = new int[50]; //declares memory for 50 integers
char selection;
Scanner input = new Scanner(System.in);
System.out.println("Welcome To Ferry Ticketing System");
selection = input.next().charAt(0);
switch(selection)
{
case 'p': case 'P':
purchasingMenu();
char purchaseoption;
System.out.println("Enter Your Selection");
purchaseoption = input.next().charAt(0);
switch(purchaseoption)
{
case 'b': case 'B': Seating();
int businessoption;
System.out.println("Enter your seat number from 1 to 10");
businessoption = input.nextInt();
System.out.println("Please Choose Your Ferry");
Scanner time = new Scanner(System.in);
displayTimetable();
char time_of_departure = time.next().charAt(0);
int B=0;
if(time_of_departure=='A') {
System.out.println("10am");
B= B+1000;
}
else if (time_of_departure=='B') {
System.out.println("11am");
B= B+1100;
}
else if (time_of_departure=='C') {
System.out.println("12pm");
B= B+1200;
}
else if (time_of_departure=='D') {
System.out.println("1pm");
B= B+1300;
}
else if (time_of_departure=='E') {
System.out.println("2pm");
B= B+1400;
}
else if (time_of_departure=='F') {
System.out.println("3pm");
B= B+1500;
}
else if (time_of_departure=='G') {
System.out.println("4pm");
B= B+1600;
}
else if (time_of_departure=='H') {
System.out.println("5pm");
B= B+1700;
}
else {
System.out.println("Select The Correct Ferry!! ");
displayTimetable();
}
System.out.println("Enter Your Name");
Scanner name = new Scanner(System.in);
System.out.println("");
String customer_name = name.next();
System.out.println("Enter Your Seat Number");
Scanner number = new Scanner(System.in);
System.out.println("");
String seat_number = number.next();
Calendar cal = Calendar.getInstance();
int day = cal.get(Calendar.DATE);
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
switch(businessoption) {
case 1: anArr[0] = anArr[0]+1; System.out.println("You have chosen B1"); break; //assign a seat number
case 2: anArr[1] = anArr[1]+1; System.out.println("You have chosen B2"); break;
case 3: anArr[2] = anArr[2]+1;System.out.println("You have chosen B3"); break;
case 4: anArr[3] = anArr[3]+1;System.out.println("You have chosen B4"); break;
case 5: anArr[4] = anArr[4]+1;System.out.println("You have chosen B5"); break;
case 6: anArr[5] = anArr[5]+1;System.out.println("You have chosen B6"); break;
case 7: anArr[6] = anArr[6]+1;System.out.println("You have chosen B7"); break;
case 8: anArr[7] = anArr[7]+1;System.out.println("You have chosen B8"); break;
case 9: anArr[8] = anArr[8]+1;System.out.println("You have chosen B9"); break;
case 10: anArr[9] = anArr[9]+1;System.out.println("You have chosen B10"); break;
default:
System.out.println("Please Choose A Valid Seat Number");
break;
}
displayMenu(); // assign the business class ticket
break;
case 'e': case 'E': Seating();
int economyoption;
System.out.println("Enter your seat number from 11 to 50");
economyoption = input.nextInt();
System.out.println("Choose Your Ferry");
Scanner time2 = new Scanner(System.in);
displayTimetable();
char time2_of_departure = time2.next().charAt(0);
int C=0;
if(time2_of_departure=='A') {
System.out.println("10am");
C= C+1000;
}
else if (time2_of_departure=='B') {
System.out.println("11am");
C= C+1100;
}
else if (time2_of_departure=='C') {
System.out.println("12pm");
C= C+1200;
}
else if (time2_of_departure=='D') {
System.out.println("1pm");
C= C+1300;
}
else if (time2_of_departure=='E') {
System.out.println("2pm");
C= C+1400;
}
else if (time2_of_departure=='F') {
System.out.println("3pm");
C= C+1500;
}
else if (time2_of_departure=='G') {
System.out.println("4pm");
C= C+1600;
}
else if (time2_of_departure=='H') {
System.out.println("5pm");
C= C+1700;
}
else {
System.out.println("Select The Correct Ferry!! ");
displayTimetable();
}
System.out.println("Enter Your Name");
Scanner name2 = new Scanner(System.in);
System.out.println("");
String customer_name2 = name2.next();
System.out.println("Enter Your Seat Number");
Scanner number2 = new Scanner(System.in);
System.out.println("");
String seat_number2 = number2.next();
Calendar cal2 = Calendar.getInstance();
int day2 = cal2.get(Calendar.DATE);
int month2 = cal2.get(Calendar.MONTH) + 1;
int year2 = cal2.get(Calendar.YEAR);
switch(economyoption) {
case 11: anArr[10] = anArr[10]+1; System.out.println("You have chosen E11"); break;
case 12: anArr[11] = anArr[11]+1; System.out.println("You have chosen E12"); break;
case 13: anArr[12] = anArr[12]+1; System.out.println("You have chosen E13"); break;
case 14: anArr[13] = anArr[13]+1; System.out.println("You have chosen E14"); break;
case 15: anArr[14] = anArr[14]+1; System.out.println("You have chosen E15"); break;
case 16: anArr[15] = anArr[15]+1; System.out.println("You have chosen E16"); break;
case 17: anArr[16] = anArr[16]+1; System.out.println("You have chosen E17"); break;
case 18: anArr[17] = anArr[17]+1; System.out.println("You have chosen E18"); break;
case 19: anArr[18] = anArr[18]+1; System.out.println("You have chosen E19"); break;
case 20: anArr[19] = anArr[19]+1; System.out.println("You have chosen E20"); break;
case 21: anArr[20] = anArr[20]+1; System.out.println("You have chosen E21"); break;
case 22: anArr[21] = anArr[21]+1; System.out.println("You have chosen E22"); break;
case 23: anArr[22] = anArr[22]+1; System.out.println("You have chosen E23"); break;
case 24: anArr[23] = anArr[23]+1; System.out.println("You have chosen E24"); break;
case 25: anArr[24] = anArr[24]+1; System.out.println("You have chosen E25"); break;
case 26: anArr[25] = anArr[25]+1; System.out.println("You have chosen E26"); break;
case 27: anArr[26] = anArr[26]+1; System.out.println("You have chosen E27"); break;
case 28: anArr[27] = anArr[27]+1; System.out.println("You have chosen E28"); break;
case 29: anArr[28] = anArr[28]+1; System.out.println("You have chosen E29"); break;
case 30: anArr[39] = anArr[29]+1; System.out.println("You have chosen E30"); break;
case 31: anArr[30] = anArr[30]+1; System.out.println("You have chosen E31"); break;
case 32: anArr[31] = anArr[31]+1; System.out.println("You have chosen E32"); break;
case 33: anArr[32] = anArr[32]+1; System.out.println("You have chosen E33"); break;
case 34: anArr[33] = anArr[33]+1; System.out.println("You have chosen E34"); break;
case 35: anArr[34] = anArr[34]+1; System.out.println("You have chosen E35"); break;
case 36: anArr[35] = anArr[35]+1; System.out.println("You have chosen E36"); break;
case 37: anArr[36] = anArr[36]+1; System.out.println("You have chosen E37"); break;
case 38: anArr[37] = anArr[37]+1; System.out.println("You have chosen E38"); break;
case 39: anArr[38] = anArr[38]+1; System.out.println("You have chosen E39"); break;
case 40: anArr[39] = anArr[39]+1; System.out.println("You have chosen E40"); break;
case 41: anArr[40] = anArr[40]+1; System.out.println("You have chosen E41"); break;
case 42: anArr[41] = anArr[41]+1; System.out.println("You have chosen E42"); break;
case 43: anArr[42] = anArr[42]+1; System.out.println("You have chosen E43"); break;
case 44: anArr[43] = anArr[43]+1; System.out.println("You have chosen E44"); break;
case 45: anArr[44] = anArr[44]+1; System.out.println("You have chosen E45"); break;
case 46: anArr[45] = anArr[45]+1; System.out.println("You have chosen E46"); break;
case 47: anArr[46] = anArr[46]+1; System.out.println("You have chosen E47"); break;
case 48: anArr[47] = anArr[47]+1; System.out.println("You have chosen E48"); break;
case 49: anArr[48] = anArr[48]+1; System.out.println("You have chosen E49"); break;
case 50: anArr[49] = anArr[49]+1; System.out.println("You have chosen E50"); break;
default:
System.out.println("Please Choose Another Seat Number");
break;
}
displayMenu(); // assign the economy class ticket
break;
case 'm': case 'M':
displayMenu();
break;
default:
System.out.println("Please Try Again!");
}
break;
case 'v': case 'V':
System.out.println("View Seating Arrangement");
Seating();
displayMenu();
break;
case 'q': case 'Q':
System.out.println("Thank you for using this service.");
System.exit(0);
break;
default:
System.out.println("Wrong Selection");
break;
}
}
public static void purchasingMenu()
{
System.out.println("*****************************************************");
System.out.println("* FERRY TICKETING SYSTEM *");
System.out.println("* PURCHASING MENU *");
System.out.println("* Select B for Business Class Ticket *");
System.out.println("* Select E for Economy Class Ticket *");
System.out.println("* Select M to return to Main Menu *");
System.out.println("*****************************************************");
}
public static void Seating()
{
System.out.println("*****************************************");
System.out.println("* Ferry ID: Date: *");
System.out.println("*****************************************");
System.out.println("* Seating Chart *");
System.out.println("*************************************************************");
System.out.println("* B1 * B2 * B3 * B4 * B5 *");
System.out.println("*************************************************************");
System.out.println("* B6 * B7 * B8 * B9 * B10 *");
System.out.println("*************************************************************");
System.out.println("* E11 * E12 * E13 * E14 * E15 *");
System.out.println("*************************************************************");
System.out.println("* E16 * E17 * E18 * E19 * E20 *");
System.out.println("*************************************************************");
System.out.println("* E21 * E22 * E23 * E25 * E25 *");
System.out.println("*************************************************************");
System.out.println("* E26 * E27 * E28 * E29 * E30 *");
System.out.println("*************************************************************");
System.out.println("* E31 * E32 * E33 * E34 * E35 *");
System.out.println("*************************************************************");
System.out.println("* E36 * E37 * E38 * E49 * E40 *");
System.out.println("*************************************************************");
System.out.println("* E41 * E42 * E43 * E44 * E45 *");
System.out.println("*************************************************************");
System.out.println("* E46 * E47 * E48 * E49 * E50 *");
System.out.println("*************************************************************");
}
public static void displayTimetable()
{
System.out.println("******* Ferry Timetable *******");
System.out.println(" (Penang to Langkawi) ");
System.out.println(" Ferry A : 10am ");
System.out.println(" Ferry B : 11am ");
System.out.println(" Ferry C : 12pm ");
System.out.println(" Ferry D : 1pm ");
System.out.println(" Ferry E : 2pm ");
System.out.println(" Ferry F : 3pm ");
System.out.println(" Ferry G : 4pm ");
System.out.println(" Ferry H : 5pm ");
System.out.println("*********************************");
}
}
It shows illegal start of expression in the line 376, 387, and 418. Need help urgently. Thanks.
Edited by Alexander, 20 November 2010 - 01:59 AM.
( [code] tags )


Sign In
Create Account


Back to top









