Program in Java! Please show sample output. Thank you! Marking standard Specific
ID: 3843981 • Letter: P
Question
Program in Java! Please show sample output. Thank you!
Marking standard
Specification Tall Building Development Loan Co. makes loans of up to $100,000 for construction projects. There are two categories of Loans-those to businesses and those to 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 abstract class that implements the LoanConstants 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 LoanConstants class to a short-term, one-year loan. Create a toString0 method that displays all the loan data. LoanConstants-A public interface class. LoanConstants includes constant values for short- term (one year), medium-term (three years), and long-term (five years) loans. It also contains constants for the company name and the maximum loan amount. BusinessLoan. A public class that extends Loan. The BusinessLoan constructor sets the interest rate to 1 percent over the current prime interest rate PersonalLoan-A public class that extends Loan. The PersonalLoan constructor sets the interest rate to 2 percent over the current prime interest rate CreateLoans-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 data entry is complete, display all the loans Save the files as Loan. java Loan Constants. java BusinessLoan. ja va Personal Loan. java. and Create Loans javaExplanation / Answer
CreateLoan.java
import java.util.Scanner;
public class CreateLoan {
public static void main(String[] args) {
int x = 0;
int primeRate;
String type;
Scanner input = new Scanner(System.in);
Loan[] lns = new Loan[5];
System.out.println(" enter the prime interest rate");
primeRate = input.nextInt();
primeRate = primeRate/100;
input.nextLine();
for(x = 0; x < 6; ++x) {
System.out.println("Please enter a loan type. Choose either Business or Personal. ");
type = input.nextLine();
if (type.equalsIgnoreCase("Business")) {
System.out.println("What is the account number ?");
int ln = input.nextInt();
System.out.println("What is the last name of the account?");
String last = input.nextLine();
input.nextLine();
System.out.println("What is the loan amount? ");
int lan = input.nextInt();
System.out.println("What is the term on the account? Enter 1 , 3 or 5");
int term = input.nextInt();
lns[x] = new BusinessLoan(ln, last, lan, term);
System.out.println("The Company's Name is " + Loan.COMPANY_NAME);
System.out.println("The loan number is " + lns[x].getLoanNumber());
System.out.println("The last name on the loan is " + lns[x].getLastName());
System.out.println("The loan amount is " + lns[x].getLoanAmount());
System.out.println("The interest rate on the loan is " + lns[x].getInterestRate());
}
else if (type.equalsIgnoreCase("Personal")) {
System.out.println("What is the account number ?");
int ln = input.nextInt();
System.out.println("What is the last name of the account?");
String last = input.nextLine();
input.nextLine();
System.out.println("What is the loan amount? ");
int lan = input.nextInt();
System.out.println("What is the term on the account? Enter 1 , 3 0r 5.");
int term = input.nextInt();
lns[x] = new PersonalLoan(ln, last, lan, term);
System.out.println("The Company's Name is " + Loan.COMPANY_NAME);
System.out.println("The loan number is " + lns[x].getLoanNumber());
System.out.println("The last name on the loan is " + lns[x].getLastName());
System.out.println("The loan amount is " + lns[x].getLoanAmount());
System.out.println("The interest rate on the loan is " + lns[x].getInterestRate());
} else {
System.out.println("Error Please restart and try again.");
System.exit(0);
}
}
}
}
PersonalLoan.java
public class PersonalLoan extends Loan {
public PersonalLoan(int ln, String last, int lan, int term) {
setLoanNumber(ln);
setLoanAmount(lan);
double primeRate = 0;
int interestRate = (int)((primeRate * 0.02) + primeRate);
setInterestRate(interestRate);
}
}
Loan.java
public class Loan extends LoanConstants{
public static int loanNumber;
public static String lastName;
public static int loanAmount;
public static int interestRate;
public static int term;
static String COMPANY_NAME;
public int primRate;
public int getLoanNumber() {return loanNumber;}
public void setLoanNumber(int n){n = loanNumber;}
public String getLastName(){return lastName;}
public void setLastName(String s){s= lastName;}
public int getLoanAmount() {return loanAmount;}
public void setLoanAmount(int n){
n = loanAmount;
int SHORT_TERM = 0;
if (term == 1){
term = SHORT_TERM;}
else if (term == 3){
} else if (term == 3) {
int MEDIUM_TERM = 0;
term = MEDIUM_TERM;
} else if(term == 5) {
int LONG_TERM = 0;
term = LONG_TERM;
} else
term = SHORT_TERM;
}
public int getInterestRate() {return interestRate;}
public void setInterestRate(int i){i = interestRate;}
public static void displayAll(){
System.out.println("The Company's Name is " + COMPANY_NAME);
System.out.println("The loan number is " + loanNumber);
System.out.println("The last name on the loan is " + lastName);
System.out.println("The loan amount is " + loanAmount);
System.out.println("The interest rate on the loan is " + interestRate);
System.out.println("The term on the account is " + term);
}
}
LoanConstants.java
public class LoanConstants {
public interface LoanConstant {
public final static int SHORT_TERM = 1;
public final static int MEDIUM_TERM = 3;
public final static int LONG_TERM = 5;
public final static String COMPANY_NAME = "Tall Building Development Loan co ";
public final static int MAX_LOAN_AMOUNT = 100000;
}
}
BusinessLoan.java
public class BusinessLoan extends Loan{
public BusinessLoan(int ln, String last, int lan, int term) {
setLoanNumber(ln);
setLastName(last);
setLoanAmount(lan);
double primeRate = 0;
int interestRate = (int)((primeRate * 0.01) + primeRate);
setInterestRate(interestRate);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.