Sanchez Construction Loan Co. (150 points) The company makes loans of up to $100
ID: 3574346 • Letter: S
Question
Sanchez Construction Loan Co. (150 points) The company makes loans of up to $100,000 for construction projects. There are two categories of loans – those for business and those for individual applicants. Write an application that tracks all new construction loans. The application must also calculate the total amount owed at the due date (original loan amount + loan fee). The application should include the following classes: Loan – A public static class that implements the LoanConstant interface. A Loan includes a loan number, customer last name, amount of loan, interest rate, and term. The constructor requires data for each of the fields except interest rate. Do not allow loan amounts over $100,000. Force any loan term that is not one of the three defined in the LoanCostants class to a short-term, one year loan. Create a toString() method that displays all the loan data. Loan Constants – A public interface class. LoanConstants includes constant values for short-term(1 year), medium-term (3 years) and long-term (5 years) loans. It also contains constants for the company names and the maximum loan amount. Business Loan – A public class that extends Loan. The BusinessLoan constructor sets the interest rate to 1% over the current prime interest rate. Personal Loan – A public class that extends Loan. The PersonalLoan Constructor set the interest rate 2% over the current prime interest rate. Create Loan – An application that creates an array of five loans. Prompt the user for the current prime interest rate. Then, in a loop, prompt the user for a loan type and all relevant information for that loan. Store the created Loan objects in the array. When the data entry is complete, display all the loans. Save the file as Loan.java, LoanConstant.java, BusinessLoan.java, PersonalLoan.java, and CreateLoans.java.
Can someone help me with this one. I got one day till break and this is gonna take a minute.
Explanation / Answer
/*The question is flawed as Java(and most programming languages) has no way of making a top-level class(In your case as required the Loan.java class) static. But still considering that is a typo, below are the files for the application.The program has been written in java jdk 1.7. Create a package with name loan and put these codes in repective files.*/
Loan.java
package loan;
public class Loan implements LoanConstant {
public int loanNumber;
public String customerLastName;
public double amountOfLoan;
public double interestRate;
public double term;
public Loan(int loanNumber,String customerLastName,double amountOfLoan,double term){
this.loanNumber=loanNumber;
this.customerLastName=customerLastName;
this.amountOfLoan=amountOfLoan;
this.term=term;
if(this.term!=shortTerm ||this.term!=mediumTerm||this.term!=longTerm)
this.term=1;
if(this.amountOfLoan>loanAmount){
System.out.println("Loan amount not allowed");
return;
}
}
public void displayData()
{
System.out.println("Loan Number: "+this.loanNumber);
System.out.println("Customer Last Name: "+this.customerLastName);
System.out.println("Amount Of Loan: "+this.amountOfLoan);
System.out.println("Term: "+this.term);
}
}
LoanConstant.java
package loan;
public interface LoanConstant {
int shortTerm=1;
int mediumTerm=3;
int longTerm=5;
String companyName="Grizlaa";
int loanAmount=100000;
}
BusinessLoan.java
package loan;
public class BusinessLoan extends Loan {
public BusinessLoan(int loanNumber, String customerLastName, double amountOfLoan, double term,double rate)
{
super(loanNumber, customerLastName, amountOfLoan, term);
interestRate=(101*rate)/100;
}
}
PersonalLoan.java
package loan;
public class PersonalLoan extends Loan{
public PersonalLoan(int loanNumber, String customerLastName, double amountOfLoan, double term,double rate)
{
super(loanNumber, customerLastName, amountOfLoan, term);
interestRate=(102*rate)/100;
}
}
CreateLoans.java
package loan;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CreateLoans {
public static void main(String args[])throws IOException
{
Loan array[]=new Loan[5];
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the prime interest rate : ");
double rate=Double.parseDouble(br.readLine());
String in="";
BusinessLoan b=null;
PersonalLoan p=null;
for(int i=0;i<5;i++)
{
System.out.print("Enter the Loan type(business/personal) : ");
in=br.readLine();
if(in.equalsIgnoreCase("business"))
{
System.out.print("Enter the loan Number : ");
int loanNumber=Integer.parseInt(br.readLine());
System.out.print("Enter the customer last name : ");
String customerLastName=br.readLine();
System.out.print("Enter the loan amount : ");
double amountOfLoan=Double.parseDouble(br.readLine());
System.out.print("Enter the loan term : ");
double term=Double.parseDouble(br.readLine());
b=new BusinessLoan(loanNumber, customerLastName, amountOfLoan, term,rate);
array[i]=b;
}
else if(in.equalsIgnoreCase("personal"))
{
System.out.print("Enter the loan Number : ");
int loanNumber=Integer.parseInt(br.readLine());
System.out.print("Enter the customer last name : ");
String customerLastName=br.readLine();
System.out.print("Enter the loan amount : ");
double amountOfLoan=Double.parseDouble(br.readLine());
System.out.print("Enter the loan term : ");
double term=Double.parseDouble(br.readLine());
p=new PersonalLoan(loanNumber, customerLastName, amountOfLoan, term,rate);
array[i]=p;
}
}
System.out.println("The Loan Details are:-");
for(int i=0;i<5;i++)
{
System.out.println("Loan Details "+i+": ");
System.out.println("Company Name:"+LoanConstant.companyName);
System.out.println("Loan Number: "+array[i].loanNumber);
System.out.println("Customer Last Name: "+array[i].customerLastName);
System.out.println("Amount Of Loan: "+array[i].amountOfLoan);
System.out.println("Term: "+array[i].term);
System.out.println("InterestRate: "+array[i].interestRate);
System.out.println("---------------------------------------");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.