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("*********************************************");
    }
}

Recommended Answers

All 13 Replies

char seating[seating = new int(50)];
//should be
char seating[] = new char[50];

You could really create a "level" class that has a particular number of seats and can be asked if it is full.
You can then make the Ferry have a collection of Levels.

Thank you thines01
actually as you said, i replaced and fixed the error on line 6.
now i have problem in line 14.This is the output of the compiler:
subMenu();
^
symbol: method subMenu()
location: class FerryTicketingSystem
1 error

and then at then end of compiling i have another error that said :
--------------------Configuration: <Default>--------------------
Error: Could not find or load main class FerryTicketingSystem

Process completed.

this is for general output.

And can you please explain more about "level" class and make example for me.
thank you very much
Regards

subMenu();
^
symbol: method subMenu()
location: class FerryTicketingSystem

You have left off what the error was.
Please post the full text of the compiler's error message.

One is "subMenu" and the other is "SubMenu"

subMenu() is the standard way to spell a method name. Starts with lower case

Thank you some much from thines01!
You are so clever and awsome. thank you very much.
and thank you from NormR1 for reply.
now all of the problems solved and the program build so successfully.
I have a problem in section 3,4,5,6 and i don't have any good idea to do them.
Can i know your idea and opinion how to do them?!

I wrote these codes with my bad idea for section 3,4,5,6.
But don't pay attention to my codes and my idea! :D
i don't think it is really good and work.
These are my codes for those sectios:

package ferryticketsystem;

import java.util.HashMap;

public class GUI extends javax.swing.JFrame {

    private HashMap<Integer, String> passengerList = new HashMap<Integer, String>();
    private HashMap<Integer, FerryDataHolder> ferries;
    /** Creates new form GUI */
    public GUI() {
        initComponents();
        initParam();
    }

    private void initParam() {
        jTabbedPane1.setMnemonicAt(0, 'M');
        jTabbedPane1.setMnemonicAt(1, 'P');
        jTabbedPane1.setMnemonicAt(2, 'V');
        quitButton.setMnemonic('Q');

        //Init ferries
        ferries = new HashMap<Integer, FerryDataHolder>();

        ferries.put(1, new FerryDataHolder(1));
        ferries.put(2, new FerryDataHolder(2));
        ferries.put(3, new FerryDataHolder(3));
        ferries.put(4, new FerryDataHolder(4));
        ferries.put(5, new FerryDataHolder(5));
        ferries.put(6, new FerryDataHolder(6));
        ferries.put(7, new FerryDataHolder(7));
        ferries.put(8, new FerryDataHolder(8));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        quitButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        label1 = new java.awt.Label();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel1.setText("<strong class="highlight">Ferry</strong> Ticketing System");

        jLabel2.setText("Press Alt + 'P' to purchase ticket");

        jLabel3.setText("Press Alt + 'V' to View seating arrangement");

        jLabel4.setText("Press Alt + 'Q' to Quit the system");

        quitButton.setText("Quit");
        quitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4))
                .addContainerGap(154, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(303, Short.MAX_VALUE)
                .addComponent(quitButton)
                .addGap(51, 51, 51))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(126, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(102, 102, 102))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(49, 49, 49)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addComponent(quitButton)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Main", jPanel1);

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel5.setText("Purchasing Module");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel7.setText("Buy:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel8.setText("Press Alt + 'M' to return to main menu");

        jButton1.setText("Purchase ticket for Buisness class");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Purchase ticket for Economy class");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(135, Short.MAX_VALUE)
                .addComponent(jLabel5)
                .addGap(124, 124, 124))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jLabel7)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton2)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jButton1)
                                .addGap(205, 205, 205)
                                .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(jLabel7)
                .addGap(22, 22, 22)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addGap(31, 31, 31)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addComponent(jLabel8)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Purchase Tickets", jPanel2);

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel6.setText("Seating Arrangement");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(127, Short.MAX_VALUE)
                .addComponent(jLabel6)
                .addGap(115, 115, 115))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addContainerGap(193, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Seating Arrangement", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 412, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void quitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitButtonActionPerformed
        System.exit(0);
    }//GEN-LAST:event_quitButtonActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private java.awt.Label label1;
    private javax.swing.JButton quitButton;
    // End of variables declaration//GEN-END:variables
}

and have a look to these ones :

package ferryticketsystem;

public class FerryDataholder {

    //Initialize parameters
    private int ID = 0;
    private boolean[] businessClassSeats = {false, false, false, false, false, false, false, false, false, false};
    private boolean[] economyClassSeats = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
    private int seatNumber = 0;

    public FerryDataholder(int ID) {
        this.ID = ID;
    }

    public int getID() {
        return ID;
    }


    private boolean isBusinessSeatAvailable() {   //True = Yes!
        for (int i = 0; seatNumber < businessClassSeats.length; ++i) {
            if (businessClassSeats[i] == false) {
                seatNumber = i + 1;
                return true;
            }
        }
        return false;
    }

    private boolean isEconomySeatAvailable() {   //True = Yes!
        for (int i = 0; seatNumber < economyClassSeats.length; ++i) {
            if (economyClassSeats[i] == false) {
                seatNumber = i + 1;
                return true;
            }
        }
        return false;
    }

    //Returns 'true' if success
    public boolean makeEconomySeatReservation(){
        seatNumber = -1;
        if(isEconomySeatAvailable()){
            economyClassSeats[seatNumber-1] = true;
            return true;
        }
        return false;
    }
///ahmed
     public boolean makeBuisnessSeatReservation(){
        seatNumber = -1;
        if( isBusinessSeatAvailable()){
           businessClassSeats[seatNumber-1] = true;
            return true;
        }
        return false;
    }

///

    public int getSeatNumber() {
        return seatNumber;
    }

}

Do you have any specific questions or problems about your program?

My dear NormR1, i'm so sorry for too many questuin i asked!
this is my first year of level one in bachelor of IT(Information Technology).
I hava a subject that it is java programming. i try my best for this subject, my lecterur is not good, and she didn't teach this programming language as well.
I tried my best to learn it and do it! but really i become confused! i know this language, but i don't know what should i do exactly!
If it is possible for you, please help me to finishing this program, if not, thanks for your help and i don't want to disturb you any more my dear! :(
Regards

You need to ask specific questions if you want help.
Take the sections one at a time. Design the code for one section, write it and try to get it to compile and execute. When you have problems or questions post them here.

I just want some guidelines or idea to do the other sections of program! anyone can help me and give me some suggestion to do that?!

What work have you done to solve your problem? Show some work and ask some questions.

This is some idea that i think about that.

public class Ferry_Ticketing_System {

	String destination = "d";
	String ferry_id = "id";
	int departure_time = "t";
	int BusinessClassSeatNo, EconomyClassSeatNo;
	String[] seats = new string[50];

	public string CheckBusinessSeat (){
		for (int i = 0; i < 10; i++){
			10[i]=i;
		BusinessClassSeatNo = i + 1;
		}
		for (int i = 10; i < seats.length; i++){
			seats[i]=i;
		EconomyClassSeatNo = i + 1;
		}
	}
}

My real problem is that i don't have any idea for another section to continiue the program.

Pick one of the sections you want to work on, post what you think you need to code to implement it and ask specific questions about how to do it.

Remember its your homework. We expect you to do most of the work. We're here to help you to write your program.
Unless you start showing some effort, this will be my last post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.