Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Train Tickets Machine: Write a JAVA program to sell train tickets. There are three type of tickets A,B,C to New jersey, New York. The prices

Train Tickets Machine:

Write a JAVA program to sell train tickets.

There are three type of tickets A,B,C to New jersey, New York.

The prices are as follow:

New Jersey : $15.00 (C), $17.75(B), $20.90 (A)

New York : $17.50 (C), $19.75(B), $22.50 (A)

There are 10 tickets of each type (Total=60 tickets)

The program will ask the user which tickets he want to buy, then ask him to put money,

The program will accept: $100,$50,$20,$10,$5,$1 dollars bills, and 25,10,5 cents coins.

The program should reject any other amount.

The program will keep asking the user for more money till the money amount put is equal to or more than the price of the ticket, If it is more, the program will return the exceeding amount.

Then the program will continue indefinitely asking users which ticket they want to buy.

If there are no more ticket available of certain type, the program should display this at the beginning.

If no ticket are available in the machine at all, the message displays should be : Machine closed: SOLD OUT.

Example of output (The output of your program should be like this)

Which state you buy ticket to: (1: New jersey, 2: New York): 2

Which ticket class you want to buy (1: A, 2: B, 3:C): B

The price of New York ticket class B is : $19.75

Please put money in the machine:$ 5

You have $5, put more: $17

Rejected, You have $5, put more: $1

You have $6, put more: $.25

You have $6.25, put more: $10

You have $16.25, put more: $5

Thank you.

Please take your ticket.

You change is $1.50, please take them

New York ticket class B are SOLD OUT.

Which state you buy ticket to: (1: New jersey, 2: New York): 2

Which ticket class you want to buy (1: A, 3:C):

Please do this program in Java and the output of the program should be similar to the example that I provided above.

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

Students also viewed these Databases questions

Question

At what level(s) was this OD intervention scoped?

Answered: 1 week ago