Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Train Ticket Reservation System in Java Requirements for Train Ticket Reservation System Origin is Train Station N Total of three different trips for Train Station

Train Ticket Reservation System in Java

Requirements for Train Ticket Reservation System

  • Origin is Train Station N

  • Total of three different trips for Train Station N **( Train Station N to Train Station A, Train Station N to Train Station B, and Train Station N to Train Station C)

  • Each trip is an instance of a class

  • Within this class, it should have an origin and destination coded with strings, a train ticket number that is determined through a static instance variable, the capacity and the number of booked passengers using integers and the fare using real value function.

There are 3 parts to the program

  1. Information on the three train trips. (Included as a method within the client program)

  2. The code should output the flight information

  3. Ask the user if they would like to buy train tickets

  • When the answer is yes proceed to ask the user for the destination of the train ride **(If there are no train trips with the destination print the message No Train Trips Available for that Destination)

  • Ask how many tickets will be bought. Use a boolean function within a method to determine if there is room. If there is room use a separate method to determine the fare using a real value function.

  • Continue to ask the user if it would like to buy train tickets until the answer is No

*Key components of the code

  • Proper Response when no trips are available for a destination

  • Proper Response for enough tickets

  • Only allow the user to make purchases on one trip

  • Allow the user to purchase more than one ticket on the same trip

Information for Trip 1

Origin: Train Station N

Destination: Train Station A

Current Booked Tickets: 180

Capacity: 200

Ticket Price for 1 Person: 10$

Information for Trip 2

Origin: Train Station N

Destination: Train Station B

Current Booked Tickets: 200

Capacity: 300

Ticket Price for 1 Person: 20$

Information for Trip 3

Origin: Train Station N

Destination: Train Station C

Current Booked Tickets: 300

Capacity 400

Ticket Price for 1 Person: 30$

Example:

The code should show information for all 3 train trips (Origin, Destination, Capacity, Number of Booked Seats, and Ticket Price as well as Train Number)

As the user, I would like to the train trip from Train Station N to Train Station A and I would like to purchase 5 tickets

The user will be told that there are available seats and the price of the tickets are

After the purchase, the information of available seats would be updated

If the user attempts to purchase a number of tickets that exceeds the number of available seats the code will print the message Not enough available seats

The code should be simple and use global variables as well as local variables.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

Technology. Refer to Case

Answered: 1 week ago