Question: write a java code - Three instance data members of private access modifier: memberid: represents the id of the member and its data type is

- Three instance data members of private access modifier: memberid: represents the id of the member and its data type is integer. membershipType: represents the display type of the membership and its data type is string. totalfee: represents the cost that members pay and its data type is double. - One static data member of public access modifier: membersCounter: keeps track of the number of member's objects that are created from the GymMembership class. Its type is integer. - Member methods as follows: 1. Default constructor to initialize the memberid to zero, membershipType to empty string, and the totalfee to zero. 2. Parameterized constructor that receives values for the following data members (totalfee, membershipType, and totalfee), then it sets the received values in the class data members. 3. Create a method named setTotalfee that sets a value in the totalfee data member, Be sure that the value is nonnegative. 4. Create a method named get Memberid that returns the value of the memberid. 5. Create a method named isExpensive that returns true if the total fee is more than or equals to 300JD, and returns false otherwise. 6. Create a method named calculateFee that returns the annual cost required for the membership according to the following: - If you only enroll for a month (Monthly), the fee to pay is 45JD. - If you want a single yearly payment (Annually), the fees to pay is 35JD per month. [Hint: = TotalFee =cost per month "number of months] 7. Create a method named showMembershipDetails that prints the values of the data members in the following format: Example 1: If the values in the created object is (memberld =991, membershipType = "Annually", totalfee =40 ) Your membership id is 791 and its type is Annually. You need to pay 480. However, this is an expensive gVm! O 2021-2022 faculty of Infocmation Rectinology ifIT, Applied Scicace Chivenity. Ammun. Jordin. Example 2: If the values in the created object is (memberid =7771, membershipType = "Monthly", totalfee =55 ) Example 1: If the values in the created object is (memberid = 991 , membershipType = "Annually", totalFee =40) Your membership id is 791 and its type is Annually. You need to pay 480. However, this is an expensive gym! 6. 2021-2022 Faculty of Information Technology (FIT). Applied Science University, Amman, Jordan. Example 2: If the values in the created object is (memberld =7771, membershipType = "Monthly", totalFee =551 Your membership id is 7771 and the type is Monthly. You need to pay 55. However, it is a cheap gym! [Hint: you may use the isExpensive function to detect if the gym membership is cheap or expensive]. B. Write a Demo class that contains the main method. In the main method do the following: 1. Create an object of the GymMembership class named GymMember1 using the default constructor. Create another object of the GymMembership class named GymMember2 using the parameterized constructor. Ask the user to input the memberid, membershipType, totalFee. 2. Call the method setTotalFee for the GymMember1 object to set the price of that object to be 75. 3. Print the value of the membersCounter static data member. 4. Call the showMembershipDetails method using the object GymMember1. 5. Call the showMembershipDetails method using the object GymMember2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
