Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you will use Hash table to store trainees of a Gym. The program will store records of the trainees with the following data: the name

you will use Hash table to store trainees of a Gym. The program will store records of the trainees with the following data: the name of the Trainee, weight, enrollment date and height. The name will be the key of your data structure. A menu of choices should be displayed as follows: The hash function that will be used is: Take the first character of the Trainee name, convert it into uppercase. Take the last character and Convert it into Uppercase, Convert both of them to ASCII. Cast them into int. Add them Together Raise the result into the power of 2. The final result to % table size. For Example: Assume the String is Nasser and the table size = 7. Then: N= 65, h to be H = 72, the hash code = (65 + 72) 2 = 28561 %7 = 1 In case of Collision, Use Chaining with a Double Linked List, Write the code yourself from the scratch without using libraries or collections. Welcome to Gym. Enter: 1. Add a new record 2. Print the table 3. Calculate average weight. 4. Quit You need to write and submit a java program that includes three classes: Trainee.java, Gym.java and Test.java. In the Test class, create an object of class Gym with size 7. Add your sample output as a comment at the end of the Test class.

Sample output :

Welcome to Gym.

Enter: 1. Add a new record 2. Print the table 3. Calculate average weight of all trainees. 4. Quit 1 Enter the Trainee name or * to Stop: Nasser Enter Weight: 90 Enter Height: 186 Enter Enrollment Date ( Year Month Day ): 2020 12 1 Enter the Trainee name or * to Stop: Mohammed Enter Weight: 70 Enter Height: 165 Enter Enrollment Date ( Year Month Day ): 2019 9 11 Enter the Trainee name or * to Stop: Jarah Enter Weight: 70 Enter Height: 160 Enter Enrollment Date ( Year Month Day ): 2020 5 5 Enter the Trainee name or * to Stop: * Welcome to Gym. Enter: 1. Add a new record 2. Print the table 3. Calculate average weight of all trainees. 4. Quit 2 Trainee Height Weight Enrollment Date Nasser 186 90 2020 12 1 Mohammed 165 70 2019 9 11 Jarah 160 70 2020 5 5 Welcome to Gym. Enter: 1. Add a new record 2. Print the table 3. Calculate average weight of all trainees. 4. Quit 3 Average weight = 70 KG Welcome to Gym. Enter: 1. Add a new record 2. Print the table 3. Calculate average weight of all trainees. 4. Quit 4 Goodbye!

DATA STRUCTURE USE JAVA!

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions