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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 13PE
icon
Related questions
Question
Enter lessee name >> Wyle Coyote
Enter apartment number » 123
Enter rent » 500
Enter lease term in months >> 24
Enter lessee name >> Yosemite Sam
Enter apartment number >> 456
Enter rent » 750
Enter lease term in months >> 12
Enter lessee name >> Bugs Bunny
Enter apartment number » 99
Enter rent » 1500.5
Enter lease term in months >> 10
Your lease results
: Wyle Coyote
: 123
: $500.00
: 24
Name
Apartment
Rent
Term
A pet fee of $10.00 is added to the monthly rent.
Your lease results
: Wyle Coyote
: 123
: $510.00
: 24
Name
Apartment
Rent
Term
Your lease results .
: Yosemite Sam
: 456
: $750.00
: 12
Name
Apartment
Rent
Term
Your lease results .
Name
Apartment
Rent
Term
: Bugs Bunny
: 99
: $1,500.50
: 10
Your lease results .
Name
Apartment
Rent
Term
: XXX
: 0
: $1,000.00
: 12
Transcribed Image Text:Enter lessee name >> Wyle Coyote Enter apartment number » 123 Enter rent » 500 Enter lease term in months >> 24 Enter lessee name >> Yosemite Sam Enter apartment number >> 456 Enter rent » 750 Enter lease term in months >> 12 Enter lessee name >> Bugs Bunny Enter apartment number » 99 Enter rent » 1500.5 Enter lease term in months >> 10 Your lease results : Wyle Coyote : 123 : $500.00 : 24 Name Apartment Rent Term A pet fee of $10.00 is added to the monthly rent. Your lease results : Wyle Coyote : 123 : $510.00 : 24 Name Apartment Rent Term Your lease results . : Yosemite Sam : 456 : $750.00 : 12 Name Apartment Rent Term Your lease results . Name Apartment Rent Term : Bugs Bunny : 99 : $1,500.50 : 10 Your lease results . Name Apartment Rent Term : XXX : 0 : $1,000.00 : 12
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

Here, I have to write a java solution to the above question.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT