Create a class named Lease with fields that hold an apartment tenant’s name, apartmentnumber, monthly rent amount, and term of the lease in months. Include a constructor thatinitializes the name to “XXX”, the apartment number to 0, the rent to 1000, and the term to12. Also include methods to get and set each of the fields. Include a nonstatic methodnamed addPetFee() that adds $10 to the monthly rent value and calls a static methodnamed explainPetPolicy() that explains the pet fee. Save the class asLeaseYourlastname.java. Replace ‘Yourlastname’ with your real last name.b) Create a class named TestLease whose main() method declares four Lease objects. Call agetData() method three times. Within the method, prompt a user for values for each fieldfor a Lease, and return a Lease object to the main() method where it is assigned to one ofmain()’s Lease objects. Do not prompt the user for values for the fourth Lease object, but letit continue to hold the default values. Then, in main(), pass one of the Lease objects to ashowValues() method that displays the data. Then call the addPetFee() method using thepassed Lease object and confirm that the fee explanation statement is displayed. Next, callthe showValues() method for the Lease object again and confirm that the pet fee has beenadded to the rent. Finally, call the showValues() method with each of the other threeobjects; confirm that two hold the values you supplied as input and one holds theconstructor default values. Save the application as TestLeaseYourlastname.java. Replace‘Yourlastname’ with your real last name.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here