I have problem in java 2 code: lease.setApartmentNumber(sc.nextLine());  melt:String cannot be converted to int and  lease.setMonthlyRent(sc.nextLine());  melt introduce variable and  lease.setPeriod(sc.nextLine()); melt: introduce variable System.out.println("Tenant's Name"+lease.getTenantName()+"\nApartment Number:"+lease.getApartmentNumber()+"\nMonthly Rent:"+NumberFormat.getCurrencyInstance().format(lease.getMonthlyRent())+"\nTerm of lease in month;"+lease.getPeriod()); }    melt: create Object getMonthlyRent()

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

I have problem in java 2 code:

lease.setApartmentNumber(sc.nextLine());  melt:String cannot be converted to int and 

lease.setMonthlyRent(sc.nextLine());  melt introduce variable and 

lease.setPeriod(sc.nextLine()); melt: introduce variable

System.out.println("Tenant's Name"+lease.getTenantName()+"\nApartment Number:"+lease.getApartmentNumber()+"\nMonthly Rent:"+NumberFormat.getCurrencyInstance().format(lease.getMonthlyRent())+"\nTerm of lease in month;"+lease.getPeriod());
}    melt: create Object getMonthlyRent()

 

 

Java 1:

package lease;


public class Lease {

private String tenantName;
private int apartmentNumber;
private double monthlyRent;
private int Period;

public Lease() {
apartmentNumber = 0;
int monthlyRent = 10000;
int Period = 12;

}

// Getter Method
public String getTenantName() {
return tenantName;
}

public void setTenantName(String tenantName) {

this.tenantName = tenantName;
}

public int getApartmentNumber() {
return apartmentNumber;
}

public void setApartmentNumber(int apartmentNumber) {
this.apartmentNumber = apartmentNumber;
}

public double getMonthlyTent() {
return monthlyRent;
}

public void setMonthlyRent(double monthlyRent) {
this.monthlyRent = monthlyRent;
}

public int getPeriod() {
int period = 0;
return period;

}

public void setPeriod(int period) {
this.Period = Period;

}
}

 

Java 2:

package lease;

import java.text.NumberFormat;
import java.util.Scanner;

public class TestLease {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Declare the objects
Lease lease1=new Lease();
Lease lease2=new Lease();
Lease lease3=new Lease();
lease1=getData();
lease2=getData();
lease3=getData();
System.out.print("Display info of tenants\n\n");

showValues(lease1);
showValues(lease2);
showValues(lease3);
System.out.print("\n");
}

public static Lease getData() {

Scanner sc = new Scanner(System.in);
Lease lease = new Lease();

System.out.print("Enter tenant's name:");
lease.setTenantName(sc.nextLine());

System.out.print("Enter apartment number:");
lease.setApartmentNumber(sc.nextLine());


System.out.print("Enter monthly rent: $");
lease.setMonthlyRent(sc.nextLine());

System.out.print("Enter term of lease in months:");
lease.setPeriod(sc.nextLine());
return lease;
}

public static void showValues(Lease lease) {


System.out.print("\n=======================\n");

System.out.println("Tenant's Name"+lease.getTenantName()+"\nApartment Number:"+lease.getApartmentNumber()+"\nMonthly Rent:"+NumberFormat.getCurrencyInstance().format(lease.getMonthlyRent())+"\nTerm of lease in month;"+lease.getPeriod());
}

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 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