Consider a text file named memberships.txt that contains data relating to Fitness Club memberships. Each line within the file contains the following data items:

  • first name (a string)
  • surname (a string)
  • age (an integer)
  • membership type (a string, possible values are gym or circuit)
  • weight in kilograms (a float)
  • membership fee paid (a float),

Each data item is separated in the file by a space character. Hence, the data file contains data like the following:


Justin Time 23 gym 75.2 59.95

Eileen Over 21 circuit 45.7 59.95

Bob Down 19 circuit 89.1 160.50

Laura Norder 22 gym 65.5 120.00

Tasks

Write a Java program that uses the memberships.txt file as an input file and that performs the following tasks:

  • creates an on-screen report which shows the total number of gym and total number of circuit members and their respective average membership fee;
  • creates a text file named gym.txt that contains first name, surname, and membership fee for all members that have a gym membership. Hence, if the above example file was the input file the following would be the data in the gym.txt output file:
Justin Time 59.95
Laura Norder 120.00
  • creates a text file named circuit.txt that contains first name, surname, and membership fee for all members that have a circuit membership. Hence, if the above example file was the input file the following would be the data in the circuit.txt output file:
Eileen Over 59.95
Bob Down 160.50
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.