Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program to report information for a gym owner about the courses they offer and the income. The program needs to find some

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Write a java program to report information for a gym owner about the courses they offer and the income. The program needs to find some specific information about the registered customers, the courses details as well as the income details. The center keeps the data based on the following UML: Class Trainee Attributes - name: the full name of the trainee (first last). - weigh: the weight of the trainee. - sex: M or F. - courseName: the course that this trainee involved in. - numOfFemale: counts how many female trainee objects has been created. Methods - Trainee (String name, double w, char sex) a parameterized constructor to initialize the attributes using the passed parameters. The program should validate the weight. If a negative number passed it will replace it by the positive value, Hint: use the appropriate Math metbod. As for courseName would be initially "' . Class FitnessCourse Attributes - name: the title of the fitness course. For example, swimming, boxing, or yoga. - num: the number of trainces registered in the class. Every time a trainee is added successfully, num is incremented by 1. - numOfOW: the number of overweight trainees registered in the class. Every time an overweight trainee is added successfully increment this variabteby 1 . (A person is considered overweight if he is over 80KG ) - members: a string that contain the full name of all the trainces registered in this class. Names are separated by underscoro - - capacity: the capacity of the class, which is the maximum number of trainees who can register in this class. Methods - FitnessCourse (String n, int capa) a parameterized constructor to initialize the attributes using the passed parameters. As for the rest of the variables will be initialized to the default value. - boolean addTrainee(Trainee t ) The method adds the trainee passed to this course. returns true if the operation was completed successfully, and false otherwise. The trainee can't be added if the course is full. The trainee can't be added if he is a member already. The name of the trainee should be added to the string members The number of registered trainees should be increment with each successful addition of a trainee. The number of overweight members might be updated - boolean isMember(Trainee t ) returns true if the passed trainee is registered in this course. false if not. The trainee is registered in the course if his name appears in the string members. - boolean isFullo returns true when the class is full and returns false otherwise - double calculateIncome0 This method calculates and returns the total income from this FitnessCourse object based on the registered trainees. The prices are as follows: Special discount by 50% is applied to the overweight trainees to encourage them. You have to use "switch" statement here. - void display0 print all the attributes of a FitnessCourse object in the specified format: - Name: - Capacity: - Trainees names: > " Availability: Lf the course is full, print "This course if full." Otherwise, print "You can book this course"> Hint: use method is FullO The sample rin below show bow the output of this method should be: Cass Gym fethods - yoid main (Stringll args) the description of the main is provided in the next section. - double calcuTotallncome(FitnessCourse fe1, FitnessCourse fe2) This method receives 2 objects of class FitnessCours. The method must calculate and return the total income from the 2 objects. In class Gym, in main, do the following: 1. Create 3 FitnessCourse objects, f,f2, and f, using the following information (don't read from the user) 2. Use the method add rainee to add each of the following trainees to the swimming course fl: MahaSaad,60,FMalakAli,52,F Hala Mohammed, 88, F Print a meaningful message after adding each trainee. 3. Use the method display to print the information of the swimming course fl 4. In a meaningful message, print the total income for the course f1. 5. Use the method addTrainee to add a trainee to the boxing course f2, information sbould be taken from the user. Validate the sex entered, if it is not M or F ask the user to enter again. Print a meaningful message after adding. 6. Use the method display to print the information of the boxing course f2 7. Use the method addTrainee to add each of the following trainees to the yoga course f3: Gus Fring, 77, M Kim Wex, 59, F Print a meaningful message after adding each trainee. 8. Use the method display to print the information of the yoga course 13 9. Try to add another trainee named Kim Wex to the yoga course. 10. In a meaningful message, display how many female members the gym. 11. In a meaningful message, print the total income of the course f2, and f3. Hint: use the method calcuTotallncome Sample Run The trainee is added successfully to swimming The trainee is added successfully to swimming The trainee is added successfully to swimming Name: swimming Capacity: 15 Trainee names: Maha Saad Malak Ali Hala Mohammed Availability: You can book this course The income for f1 is: 250.0 Enter info for the boxing trainee Name: Mona Lee Wight: 77 sex: K Wrong entry, it should be M or F. Try again. sex: F The trainee is added successfully to boxing Name: boxing Capacity: 10 Trainee names: Mona Lee Availability: You can book this course The trainee is added successfully to yoga The trainee is added successfully to yoga Name: Capacity: Trainee names: Gus Fring Kim Wex Availability: You can book this course Cannot add the trainee Number of female members: 5 Income for F2 and f3:460.0 jGRASP: operation complete

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions