Hi
Actually i try to do this programming but i have some problems.
I'll become thank you if help me to fix it.
It is a simple Ferry Ticketing System with below conditions :
FERRY TICKETING SYSTEM
A small ferry company has just purchased a computer for its new automated ticketing system. The company director has asked you to design the new system to assign seats for each trip of the 50-seater ferry, which covers the route from Penang to Langkawi and back daily. The upper deck of the ferry is reserved for business class passengers and can accommodate 10 people. The main deck of the ferry, the economy class can accommodate 40 people. Assume the company has at least 8 ferries - each with a different Ferry ID, which travel at one-hour intervals from 10 am to 5 pm daily.
SECTION A : BASIC REQUIREMENTS OF THE SYSTEM
1. Main Menu
Your initial program design should display the following menu alternatives:
FERRY TICKETING SYSTEM
P – to Purchase Ticket
V –to View Seating Arrangement
Q – to Quit the system
2. Submenu
The following submenu will be displayed when P is selected:
PURCHASING MODULE
B – to purchase ticket for Business class
E – to purchase ticket for Economy class
M – to return to Main Menu
3. Assigning Seats
If the person types B, then your program should assign a seat in the business class (seats 1-10). If the person types E, then your program should assign a seat in the economy class (seats 11 - 50).
4. Boarding Ticket
Your program should then print a boarding ticket indicating the person’s name, seat number, whether it is in the business or economy class of the ferry, Date and time of departure, Source and Destination of the trip and Ferry ID.
CT010-3-1 Fundamentals of Software Development Page 2 of 4
Level 1 Asia Pacific University College of Technology & Innovation
5. Seating Chart
Use single-scripted array to represent the seating chart of the ferry, indicating the availability of the seats within each trip of the ferry. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available. Your program should never assign a seat that has already been assigned.
The Ferry ID will be requested when V is selected from the main menu and the seating arrangement for that ferry will be displayed in a tabular form, e.g.
*************************************************************
* Ferry ID : 007 Date: 19 Sept 2005 *
*************************************************************
* BUSINESS CLASS *
*************************************************************
* 1 * 1 * 1 * 0 * 0 *
*************************************************************
* 0 * 0 * 0 * 0 * 0 *
*************************************************************
* ECONOMY CLASS *
*************************************************************
* 1 * 1 * 1 * 1 * 1 *
*************************************************************
* 1 * 1 * 1 * 1 * 1 *
*************************************************************
* 0 * 0 * 0 * 0 * 0 *
*************************************************************
* 0 * 0 * 0 * 0 * 0 *
*************************************************************
* 0 * 0 * 0 * 0 * 0 *
*************************************************************
* 0 * 0 * 0 * 0 * 0 *
*************************************************************
* 0 * 0 * 0 * 0 * 0 *
*************************************************************
* 0 * 0 * 0 * 0 * 0 *
*************************************************************
6. Alternative seating
When the business class is full, your program should ask the person if it is acceptable to be placed in the economy class (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message “Next trip leaves in 1 hour”.
I'll try my best, if anyone can help me, please guide me.
Thanks
import java.util.Scanner; // to capture user input
public class FerryTicketingSystem {
public static void main(String[] args) {
char selection; // selection is a character
char seating[seating = new int(50)];
Scanner input = new Scanner(System.in);
displayMenu();
System.out.println("What is your selection? ");
selection = input.next().charAt(0); // character will be stored in this character
switch(selection) // if the user selects p, it goes to the sub menu
{
case 'p': case 'P':
subMenu();
char suboption;
System.out.println("Make a class selection"); //print: functions to run on the same line , println: functions to run on the next line
suboption = input.next().charAt(0);
switch(suboption)
{
case 'b': case 'B':
//assign business class
break;
case 'e': case 'E':
//assign economic class
break;
case 'm': case 'M':
displayMenu();
break;
default:
System.out.println("Wrong selection! Please enter the correct choice.");
}
break;
case 'q': case 'Q':
System.out.println("Good bye, Have a nice day!!");
System.exit(0); // o is an example of arguments
break;
default:
System.out.println("Wrong selection!");
break;
}
}
public static void displayMenu() // we must fix this problem where the system can run on repetition insteas of once only
{
System.out.println("*********************************************");
System.out.println("* FERRY TICKETING SYSTEM *");
System.out.println("* *MAIN MENU* *");
System.out.println("* Select P for Sub Menu *");
System.out.println("* Select Q to quit the system *");
System.out.println("*********************************************");
}
public static void SubMenu()
{
System.out.println("*********************************************");
System.out.println("* FERRY TICKETING SYSTEM *");
System.out.println("* SUB MENU *");
System.out.println("* Select B for Business Class *");
System.out.println("* Select E for Economic Class *");
System.out.println("* Select M for Main Menu *");
System.out.println("*********************************************");
}
}