Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This project develops software to help manage information about gym membership a

ID: 3779794 • Letter: T

Question

This project develops software to help manage information about gym membership and income.

A gym has many members.

Each member pays a membership fee once every quarter.

A quarter corresponds to three months, where Q1: JanuaryMarch, Q2: AprilJune, Q3: JulySeptember, and Q4 OctoberDecember.

There are three distinct membership types -- GROUP, OFF_PEAK, and PEAK -- each associated with a specific quarterly fee.

Each member may book sessions with a personal trainer (PT) which is charged at an hourly rate.

At the end of the year, income is calculated for each quarter (Q1, Q2, Q3, Q4) and a report is created for management showing the amounts received from each member for each quarter.

Data Specifications

The Gym class has at least the following private instance fields:

gymName - a string that identifies the name of the gym

members - a list of Member objects

gymRates - a map that relates membership type to its fee (a non-negative double)

trainerRate - a non-negative double indicating rate charged for one hour with a PT

The Member class has at least the following private instance fields:

firstName - a string containing the first name of the member

lastName - a string containing the last name of the member

memberType - a MembershipType for the member

trainerHours - a length 4 array of non-negative integers holding the number of hours with a personal trainer; where the indices used are symbolic constants from the Quarter enum (Q1, Q2, Q3, Q4)

Constraints for Gym and Member data

Here are some constraints on data for the Gym and Member classes.

The name of a gym has a maximum length of 25 characters. If a longer name is given it is truncated to the first 25 characters.

All rates must be greater than or equal to 0. If a negative rate is given, 0 is used instead.

The first name of a member has a maximum length of 16 characters. The last name of a member also has a maximum length of 16 characters. If a longer string is given for either, it is truncated to the first 16 characters.

The maximum number of hours for a member in any given quarter is 120. If a value less than 0 or greater than 120 is given, 0 will be used instead. (Note that values greater than 120 are set to 0, not to 120.)

Only the specified constants for MembershipType and Quarter are acceptable.

If an invalid MembershipType is given, GROUP will be used instead.

If an invalid Quarter is passed as a parameter to a method, the method will return without taking any action.

Design

The Gym class and Member class require appropriate constructors, accessors, mutators, and toString methods. (Private methods should be used as appropriate.)

Development Steps (in recommended order)

Implement the MembershipType and Quarter enumerations according to the specifications given above.

Implement the Gym and Member classes as defined in this document, the additional information about specific methods given below. Ensure that the classes address the specified constraints on data.

Submit the following files and a reflection as responses to Gym Membership - Implementation:

Gym.java

Member.java

Additional information about specific methods for the Gym class

public void addMember(String firstName, String lastName,
MembershipType memberType,
int hoursQ1, int hoursQ2,
int hoursQ3, int hoursQ4)

This adds a new member to a gym’s list of members. The hoursQ1 through hoursQ4 parameters provide the number of personal trainer hours that the member had for each quarter of the year.

public void addMember(Member member)

This adds the specified member to a gym’s list of members.

public String createAnnualReport()

This method returns a String, suitable for display on the console, with the names of each of the members and the amount of money they paid. The string returned must contain one line for each member showing the member's name followed by the total amount of money that member paid for the year.

public Member highestTrainingHours()

This method goes through the list of all members and returns the member that has the highest number of personal training hours for the year.

public int calculateTotalTrainingHours()

This method sums up all the personal training hours for the gym for the four quarters and returns that total.

Additional information about specific methods for the Member class:

public double calculateTotalSpent(Map<MembershipType,Double> gymRates,
double personalTrainerRate)

This calculates the total amount spent by this member across all four quarters. The first parameter is the map containing the actual rates as defined in the Gym class. The second parameter is the hourly rate charged for personal trainers at the gym.

public double calculateQuarterBill(double[] gymRates,
double personalTrainerRate,
Quarter quarter)

This calculates the bill for this member for the specified quarter as determined by the third parameter. The first parameter is the array containing the actual group, off-peak and peak rates as defined in the Gym class. The second parameter is the rate that personal trainers charge at the gym. The third parameter indicates the quarter.

public int getTotalTrainingHours()

This method returns this member’s total number of training hours for the four quarters.

Explanation / Answer


package gym;

import java.util.Scanner;

public class Gym {

private String gymName;
private int members;
private double gymRate;
private double trainerRate;
public enum MemberShipType { GROUP, OFF_PEAK,PEAK }
public enum quater{Q1,Q2,Q3,Q4}
  
public void setData(){
Scanner scn=new Scanner(System.in);
System.out.println("Enter the name of Gym:");
gymName=scn.next();
gymName=truncate(gymName,25);
}

private String truncate(String gymName, int length) {
if (gymName.length() > length) {
   return gymName.substring(0, length);
   } else {
   return gymName;
   }
  
}
}


package gym;

import java.util.Scanner;

public class Member {

private String firstName;
private String lastName;
private String memberType; //for invalid membership GROUP will be used instead.
private int trainerHours[]=new int[4]; //=new trainerHours[4] //maximum is 120 for each trainerHourss[i]
public void getData(){
Scanner scn=new Scanner(System.in);
System.out.println("Enter your first name:");
firstName=scn.next();
firstName=truncate(firstName,16);
System.out.println("Enter your last name:");
lastName=scn.next();
lastName=truncate(lastName,16);
System.out.println("Enter your membership type:");
memberType=scn.next();
System.out.println("Enter your trainer hours for Q1,Q2,Q3,Q4:");
trainerHours[0]=scn.nextInt();
trainerHours[1]=scn.nextInt();
trainerHours[2]=scn.nextInt();
trainerHours[3]=scn.nextInt();
}
public void addMember(Member m1){
firstName=m1.firstName;
lastName=m1.lastName;
memberType=m1.memberType;
trainerHours=m1.trainerHours;
}
private String truncate(String sn, int length) {
if (sn.length() > length) {
   return sn.substring(0, length);
   } else {
   return sn;
   }
  
}
public static void main(String[] args) {
// TODO code application logic here
}
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote