Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hash Tables in Java (eclips) Project: Train Booking System This project will implement a simple passenger/ticket lookup system using Hash Tables in Java. You should

image text in transcribed

image text in transcribed

image text in transcribed

Hash Tables in Java (eclips)

Project: Train Booking System This project will implement a simple passenger/ticket lookup system using Hash Tables in Java. You should create the Hash Table Class from scratch. You will create three classes: Passenger.java, BookingSystem.java and Test.java. For the Passenger class you will have the instant variables: String passenger_Name, String ticket_ID and double ticket_price. You will also create a constructor, getters for instant variables, setters for instant variables and toString that prints the passenger_Name, ticket_ID and ticket_price. For the Bookingsystem class, you can store a String passenger_Name, String ticket_ID, and double ticket_price. The passenger_Name will be the key and the ticket_ID and ticket_price will be the value stored. Use quadric probing for collision resolving. The hash function to be used is the following: Key = (sum +p) % size Variable Description The index used to store ticket_ID in the hashtable Sum Sum of all characters in the passenger_Name P A constant prime value of 19 Size Size of the hash table For the Test class, you will be provided with a text file containing passenger_Name (first and last names) ticket_ID and ticket_price separated by a comma. Create an object of class BookingSystem with size 13 and use the text file to fill the hash table. Then you have to choose an option from a menu. You can add a new passenger by adding a new passenger_Name ticket_ID and ticket_price to the table. You need to check if the ticket ID is valid by checking if it has 6 numbers, underscore and Two letters. An example of a valid ticket is 120321_KW. You can also Find Ticket, if the passenger_Name exist in the table then return ticket_ID otherwise passenger doesn't have a valid ticket. You can update a ticket_ID using a passenger_Name that exist in the hash table. Add your sample output as a comment at the end of the Test class. A menu of choices should be displayed as follows: Welcome to Train Booking System. Enter: 1. Add a new Passenger 2. Find Ticket 3. Update Ticket ID 4. Print Passengers table 5. Find the highest ticket price 6. Quit Sample of Passengers.txt file: Ahmed Omar, 120221_KW, 50.500 Mona Salem, 230421_KS, 62.750 Ali Fahd 150221_EG, 105.500 Zahra Sameer, 250521_QT, 77.25 Lama Abdullah, 120721_UK, 140.250 Sample of output: Welcome to Train Booking System. Enter: 1. Add a new Passenger 2. Find Ticket 3. Update Ticket ID 4. Print train booking table 5. Find the highest ticket price 6. Quit 1 Enter the passenger name or "*" to Stop: Aya Bader Enter Ticket_ID of at least 9 characters include letters, numbers and_ : 120321_KW Enter ticket price : 68.5 Enter the passenger name or "*" to Stop: Tamer Hasan Enter Ticket_ID of at least 9 characters include letters, numbers and _ : 2304KW Invalid Ticket ID Enter Ticket_ID of at least 9 characters include letters, numbers and _ : 230421_USA Enter ticket price : 594 Enter the passenger name or "*" to Stop: Aya Bader passenger already exist Enter the passenger or "* to Stop: 3. Update Ticket ID 4. Print train booking table 5. Find the highest ticket price 6. Quit 5 The highest ticket price is for Tamer Hasan with ticket_ID 230421_USA: 594 KD Welcome to Train Booking System. Enter: 1. Add a new Passenger 2. Find Ticket 3. Update Ticket ID 4. Print train booking table 5. Find the highest ticket price 6. Quit 4 Train booking table: 0 Aya Bader, 060321_TK, 120.250 1 Tamer Hasan, 230421_USA, 594.000 2 Mona Salem, 230421_KS, 62.750 3 Ahmed Omar, 120221_KW, 50.500 4 5 Ali Fahd , 150221_EG, 105.500 6 *** 7 *** 8 Zahra Sameer , 250521_QT, 77.250 10 *** 11 12 Lama Abdullah , 120721_UK, 140.250

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions