Question: Create a constructor class named Lease with fields that hold an apartment tenant's name, apartment number, monthly rent amount, and term of the lease (in

Create a constructor class named Lease with fields that hold an apartment tenant's name, apartment number, monthly rent amount, and term of the lease (in months). Have the constructor initialize the rent amount to 800 and the term to 12. Include methods to set and get each of the fields. Include a nonstatic method named addPetFee() that adds $25 to the monthly rent amount and calls a static method named explainPetPolicy() that explains the pet fee Create a program called TestLease to input a tenant's information along with the pet fee/ Save the classes as Lease.java, TestLease.java

This is what I have but I keep getting errors in the lease.getMonthlyRent.

class Lease { private String tenantName; private int apartmentNumber; private int monthlyRent = 800; private int leaseMonths = 12; public void setName(String n) { tenantName = n; } public void setApartmentNumber(int a) { apartmentNumber = a; } public void setMonthlyRent(int m) { monthlyRent = m; } public void setLease(int l) { leaseMonths = l; } public String getName () { return tenantName; } public int getApartmentNumber() { return apartmentNumber; } public int getMonthlyRent() { return monthlyRent; } public int getLease() { return leaseMonths; } public void addPetFee() { monthlyRent = monthlyRent + 25; explainPetPolicy(); } public String explainPetPolicy() {

return " include $25 monthly pet fee";

} }

import java.util.*; public class TestLease { public static void main (String [] args) { Lease lease = new Lease (); Scanner input = new Scanner (System.in); System.out.print("Tenant Name: "); lease.setName(input.nextLine()); System.out.print("Apartment Number: "); lease.setApartmentNumber(input.nextInt()); System.out.print("Lease (in months): "); lease.setLease(input.nextInt()); lease.setMonthlyRent(800); lease.addPetFee(); System.out.println("Tenant " + lease.getName() + " in apartment number " + lease.getApartmentNumber() + " has a lease of " + lease.getLease() + "months. "); System.out.println(" The monthly rent is $" + lease.getMonthlyRent); System.out.println(lease.explainPetPolicy()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!