CJCoding With Joseph
15free / daySign inCreate account

Membership is an abstract class that stores the number of months in a private field and leaves cost() abstract. Complete cost() in GymMembership. A private field of the parent is out of reach in the subclass, so the inherited getter is the way in.

Requirements: 1. Read the months with getMonths(). 2. The cost is the months multiplied by MONTHLY_RATE. 3. A plan shorter than 12 months also pays JOINING_FEE once. A plan of 12 months or more does not.

Do not change the Membership class.

Do NOT write a main method.

Expected output

3 months: 115.0
12 months: 360.0

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
Abstract ClassesClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.