Create a class named Lease with fields that hold an apartment tenant's name, apartment number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name to “XXX", the apartment number to 0, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy() that explains the pet fee. Save the class as Lease.java. b. Create a class named TestLease whose main() method declares four Lease objects. Call a getData() method three times. Within the method, prompt a user for values for each field for a Lease, and return a Lease object to the main() method where it is assigned to one of main()'s Lease objects. Do not prompt the user for values for the fourth Lease object, but let it continue to hold the default values. Then, in main(), pass one of the Lease objects to a showValues () method that displays the data. Then call the addPetFee() method using the passed Lease object and confirm that the fee explanation statement is displayed. Next, call the showValues () method for the Lease object again and confirm that the pet fee has been added to the rent. Finally, call the showValues() method with each of the other three objects; confirm that two hold the values you supplied as input and one holds the constructor default values. Save the application as TestLease.java.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Complete 13a and 13b on page 166. Reference 141 - 153.
Only use nextLine(), nextInt() and nextDouble() to retrieve data
lessee name is a String
• apartment number is an integer
rent is a double
• lease term in months is an integer
Define the pet fee as a final, static and double constant in Lease.java – at top
Use printf() to print rent and the pet fee with two decimal places
Use the pet fee constant in the addPetFee() and explainPetPolicy() methods
Definitions:
1. lessee - a person who holds the lease of a property; a tenant.
2. lease - a contract outlining the terms under which one party agrees to
rent an asset-in this case, property-owned by another party. It
guarantees the lessee, also known as the tenant, use of the property and
guarantees the lessor-the property owner or landlord-regular paymen
for a specified period in exchange.
Make sure your code has the following comments at the beginning of all
programs with the appropriate information:
//Filename
//Written by
//Date
See next page for Expected Output →
Transcribed Image Text:Complete 13a and 13b on page 166. Reference 141 - 153. Only use nextLine(), nextInt() and nextDouble() to retrieve data lessee name is a String • apartment number is an integer rent is a double • lease term in months is an integer Define the pet fee as a final, static and double constant in Lease.java – at top Use printf() to print rent and the pet fee with two decimal places Use the pet fee constant in the addPetFee() and explainPetPolicy() methods Definitions: 1. lessee - a person who holds the lease of a property; a tenant. 2. lease - a contract outlining the terms under which one party agrees to rent an asset-in this case, property-owned by another party. It guarantees the lessee, also known as the tenant, use of the property and guarantees the lessor-the property owner or landlord-regular paymen for a specified period in exchange. Make sure your code has the following comments at the beginning of all programs with the appropriate information: //Filename //Written by //Date See next page for Expected Output →
HAPTER 3
Using Methods, Classes, and Objects
a. Create a class named Lease with fields that hold an apartment tenant's name,
apartment number, monthly rent amount, and term of the lease in months.
Include a constructor that initializes the name to “XXX", the apartment
number to 0, the rent to 1000, and the term to 12. Also include methods to
13.
get and set each of the fields. Include a nonstatic method named addPetFee()
that adds $10 to the monthly rent value and calls a static method named
explainPetPolicy() that explains the pet fee. Save the class as Lease.java.
b. Create a class named TestLease whose main() method declares four Lease
objects. Call a getData() method three times. Within the method, prompt a
user for values for each field for a Lease, and return a Lease object to the main()
method where it is assigned to one of main()'s Lease objects. Do not prompt the
user for values for the fourth Lease object, but let it continue to hold the default
values. Then, in main(), pass one of the Lease objects to a showValues () method
that displays the data. Then call the addPetFee () method using the passed Lease
object and confirm that the fee explanation statement is displayed. Next, call the
showValues () method for the Lease object again and confirm that the pet fee has
been added to the rent. Finally, call the showValues() method with each of the
other three objects; confirm that two hold the values you supplied as input and
one holds the constructor default values. Save the application as TestLease.java.
Transcribed Image Text:HAPTER 3 Using Methods, Classes, and Objects a. Create a class named Lease with fields that hold an apartment tenant's name, apartment number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name to “XXX", the apartment number to 0, the rent to 1000, and the term to 12. Also include methods to 13. get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy() that explains the pet fee. Save the class as Lease.java. b. Create a class named TestLease whose main() method declares four Lease objects. Call a getData() method three times. Within the method, prompt a user for values for each field for a Lease, and return a Lease object to the main() method where it is assigned to one of main()'s Lease objects. Do not prompt the user for values for the fourth Lease object, but let it continue to hold the default values. Then, in main(), pass one of the Lease objects to a showValues () method that displays the data. Then call the addPetFee () method using the passed Lease object and confirm that the fee explanation statement is displayed. Next, call the showValues () method for the Lease object again and confirm that the pet fee has been added to the rent. Finally, call the showValues() method with each of the other three objects; confirm that two hold the values you supplied as input and one holds the constructor default values. Save the application as TestLease.java.
Expert Solution
Step 1

The program is given below for the above given question:

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY