473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Errors with Ferry Application

1 New Member
Hello;

I am beginner in java and I should submit one java program in early day.
I try to write this program more then ten time but every time I find one broblem.
Please help me because if you don't do that I am sure that I can not finish that before submited date.
I write my assignment here also I write my codes please help me and guide me with writting the enough describe.
thnaks for your help.








package javaapplication 1;

/**
*
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, departure point and destination of the trip and Ferry ID.


5. Seating Chart
Use a 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”.

*/
import java.util.Scann er;

public class Main {

/** Creates a new instance of Main */

/**
* @param args the command line arguments
*/
private static Scanner ref=new Scanner(System. in);
String Enterence;

public static void main(String[] args) {
// TODO code application logic here

MMenu();
Select(Enterenc e);
}

private static void MMenu()
{

int MAX =3;

String[] submenu = new String[MAX];

submenu[0] = new String("TO Purchase Ticket \t\t\t[Press --P-- button ]");
submenu[1] = new String("To View Seating Arrangement\t\t[Press --V-- button ]");
submenu[2]= new String("To Quit The System\t\t\t[Press --Q-- button ]");

for (int i = 0; i < MAX; i++) {
System.out.prin tln(" - " + submenu[i]);
}

Enterence=ref.n extLine();
}


private static void Select(String Select) {

if (Select.equals( "P")||Select.eq uals("p")){
SubMenu();
SelectSubmenu() ;}
else
if (Select.equals( "V")|| Select.equals(" v"))
System.out.prin tln("okey");
else
if (Select.equals( "Q")|| Select.equals(" q"))
System.out.prin tln("Do you want to exit from the software(Y/N)? ");
else
System.out.prin tln("ONLY press |P***V***Q|butt on");

}

private static void Exit()
{
System.exit(-1);
}

private static void YesNo(String YesNo)
{
Scanner refer=new Scanner(System. in);
String yes=refer.nextL ine();
if(YesNo.equals ("y")||YesNo.eq uals("Y"))
Exit();
else if (YesNo.equals(" n")||YesNo.equa ls("N"))

MMenu();
}
private static void SubMenu()
{
int MAX1 =3;

String[] submenu1 = new String[MAX1];

submenu1[0] = new String("Purchas e Ticket For Business class\t[Press --B-- Button ]");
submenu1[1] = new String("Purchas e Ticket For Economy class\t[Press --E-- button ]");
submenu1[2]= new String("Return to main menu\t\t\t[Press --M-- button ]");

for (int i = 0; i < MAX; i++)
System.out.prin tln(" - " + submenu[i]);
}

private static void SelectSubMenu(S tring SelectSubMenu)
{
if (SelectSubMenu. equals("b")||Se lectSubMenu.equ als("B"))
TimeTable();
else
if(SelectSubMen u.equals("e")|| SelectSubMenu.e quals("E"))
TimeTable();
else
if (SelectSubMenu. equals("m")||Se lectSubMenu.equ als("M"))
System.out.prin tln("return return return");
else
System.out.prin tln("ONLY press |B***E***M|butt on");

}
private static void TimeTable()
{
System.out.prin tln("Time Table :\n\n10:00\n11: 00\n12:00\n13:0 0\n14:00\n15:00 \n16:00\n17:00\ n");
System.out.prin tln("\nPlease select your suitable time movement : ");

set_time = ref.next();
SelectFerry();
}

private static void SelectFerry(Str ing SelectFerry)
{

}
}
Apr 11 '08 #1
2 2346
epots9
1,351 Recognized Expert Top Contributor
Moved to the JAVA Forums, where the resident experts can better assist you, and remember they won't give you the answer to your homework question, but giving the details you've provided they can help point you in the right direction.

**Moved from Programming Challenges
Apr 11 '08 #2
pronerd
392 Recognized Expert Contributor
Forums are generally setup to assist with specific problems and questions. They are not here to write your code for you, much less to do your homework for you.
Apr 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2351
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a similar name to the table. Rather than making a long Select Case that could become obsolete if lookup tables are added and the source table of the ListBox is edited I came up with this code.) This code works but of course it gives me build...
6
3259
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start erroring out. I see two different errors. One is a "Object reference not set to an instance of an object." error, which appears to always contain the same information, and the other is a "There is no row at position X.", where X is a number. Is this...
12
2553
by: Russ | last post by:
Hello. My new dev machine is running XP Pro. In the past all equipment has only used Windows 2000. I have had a lot of problems getting my projects up and running on the new machine. The current one is a permission error. The project is a VC++ Web Service. It works fine when the service is hosted on the old W2K dev machine, but on the new XP machine I get a permission error when the service tries to open a text file on the Windows...
1
2349
by: Ersin Gençtürk | last post by:
We couldn't find why these errors happen.They doesn't appear everytime.And they appear different pages at different times.Is there somebody know why these happenes ? First user gets this error : Server : WEB System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an
2
1615
by: Marty McDonald | last post by:
Many of our apps are in production and they do not have proper error logging in them - unhandled errors are seen by the users in the form of error messages and stack traces. I know how to make apps handle their errors (global.asax.cs "application_error" event, web.config "customErrors" section, etc). But can I do this without having to visit each app? Can this be done at the machine level? I'm looking for a kind of machine-level...
1
1080
by: Srini | last post by:
Hi, What is the best method to share the application defined errors in C# ASP.NET application. Basically I would like to have all the errors defined in one place and share those between modules of the application. In C++ I can define all the errors in a header file and include it in the CPP files and use those defined errors. In .Net is there something similar to that? or Do I have to create an assembly for all shared data and use that...
10
2215
by: dbuchanan | last post by:
Hello, >From time to time my vb2005 form disappears and is replaced by the following errors. Rebuilding the application never helps. However the errors never affects the operation of my application that I notice, but it is very anoying. To get rid of the errors I must close the form, close the application and then reopen it.
11
1676
by: Howard Kaikow | last post by:
I'm using the code below, but an error is not getting trapped. Where can such errors occur? In another process? Try SomeCode Catch ex As Exception Dim strMsg() As String = Split(ex.ToString, vbCrLf) With lstStuff For i = 0 To UBound(strMsg)
25
2373
by: JJ | last post by:
I only want to catch 404 errors at the application level (the rest are will be handled by the customerrors section of the web.config). How do I check for the error code in the Application_Error of Global.asax ? Thanks, JJ
2
2731
by: pssraju | last post by:
Hi, At present application was built on solaris 9 using sun studio 9 (Sun C++ 5.6) & rouguewave sorce pro 5. We are planning to port the same application onto SuSE Linux 9.5.0 using GCC 3.3.3 & RW source pro 9. My application heavily uses RW tools through wrapper classes on the top existing RW classes. RW libraries were built using gcc on linux platform and standalong RW examples are working fine. Since the application compilation is moving...
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.