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...


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());
}


}

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here