Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I can't get my code to output correctly, I have what it should look like under my code. Can someone show me how to do

I can't get my code to output correctly, I have what it should look like under my code. Can someone show me how to do it?

public class Lease

{

private String name;

private double apartmentNumber;

private double rent;

private double term;

public Lease()

{

name = "xxx";

apartmentNumber = 0;

rent = 1000;

term = 12;

}

public void setname(String nm)

{

name = nm;

}

public void setapartmentNumber(double aptNum)

{

apartmentNumber = aptNum;

}

public void setrent(double r)

{

rent = r;

}

public void setterm(double t)

{

term = t;

}

public String getname()

{

return name;

}

public double getapartmentNumber()

{

return apartmentNumber;

}

public double getrent()

{

return rent;

}

public double getterm()

{

return term;

}

public void addPetFee()

{

rent += 10;

explainPetPolicy();

}

public static void explainPetPolicy()

{

System.out.println("Pet policy ");

}

}

import java.util.Scanner;

public class TestLease

{

public static void main(String[] args)

{

Lease lease1 = new Lease();

Lease lease2 = new Lease();

Lease lease3 = new Lease();

Lease lease4 = new Lease();

lease1 = getdata(lease1);

lease2 = getdata(lease2);

lease3 = getdata(lease3);

showValues(lease1);

lease1.addPetFee();

showValues(lease1);

showValues(lease2);

showValues(lease3);

showValues(lease4);

}

public static Lease getdata(Lease lease)

{

Scanner input = new Scanner(System.in);

System.out.print("Enter name >> ");

lease.setname(input.nextLine());

System.out.print("Enter apartment number >> ");

lease.setapartmentNumber(input.nextDouble());

System.out.print("Enter rent >> ");

lease.setrent(input.nextDouble());

System.out.print("Enter term >> ");

lease.setterm(input.nextDouble());

return lease;

}

public static void showValues(Lease lease)

{

System.out.println("Lease name " + lease.getname());

System.out.println("Lease apartment number " + lease.getapartmentNumber());

System.out.println("Lease rent " + lease.getrent());

System.out.println("Lease term " + lease.getterm());

}

}

the output should look like this what is shown below

Your lease results:

Name : Jane Doe

Apartment : 21

Rent : 1654.0

Term : 13

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. What are your creative strengths?

Answered: 1 week ago