loanCreator.java:
/*
* Use constants when necessary, define with proper scope
*
* Create Person class with data fields of firstName and lastName
these fields can not change.
*
* Create Loan class with data fields of Person, loan Amount, term
and interest rate
* If term is not past in then default value is 36
* If interest is not past in then default value is 5.0
*
* In Loan class create method to construct output String
*
* The loan for: Fred Wasup
* The loan amount is 20000
* The term is 60
* The interest rate is %6.5
*/
package edu.hfcc;
public class LoanCreator {
public String execute(String firstName, String
lastName, int loanAmount, Integer term, Double interestRate)
{
String output = "";
if (term == null &&
interestRate == null) {
//Construct Loan
class with constructor for Person and Loan Amount
//Assign output
to method created in Loan class constructing output string
} else if (term == null &&
interestRate != null) {
//Construct Loan
class with constructor for Person and Loan Amount And
Interest
//Assign output
to method created in Loan class constructing output string
} else if (term != null &&
interestRate == null) {
//Construct Loan
class with constructor for Person and Loan Amount And term
//Assign output
to method created in Loan class constructing output string
} else {
//Construct Loan
class with constructor for Person and Loan Amount And term and
interest rate
//Assign output
to method created in Loan class constructing output string
}
return output;
}
}
LoanCreatorApp.java:
/*
* This app will print to console the first and last name of person
getting a loan and loan amount based upon value passed in
*
* The value for term and interest rate will print if value passed
in
* If no value for term then the default value of 36 will be used
otherwise the value passed in will be printed
* If no value for interest rate then the default value of 5.0 willl
be used otherwise the value passwed in will be printed
*
* DO NOT CHANGE THIS FILE
*
* REMEMBER TO RUN TEST TO VERIFY OUTPUT
*
* Under src/main/test you will see CalculateAreaTest
* Right click on the file and you will see Run As
* Click Run As and you will see JUnit Test
* Click JUnit Test and you will the test and see if you are GREEN
or RED
*/
package edu.hfcc;
public class LoanCreatorApp {
public static void main(String[] args) {
LoanCreator loanCreator = new LoanCreator();
System.out.println("All parameters passed");
System.out.println(loanCreator.execute("Fred", "Wasup", 25000, 48,
6.2));
System.out.println("Only necessary parameters using default
values");
System.out.println(loanCreator.execute("Fred", "Wasup", 25000,
null, null));
System.out.println("Passing needed parameters and term , using
default interest rate");
System.out.println(loanCreator.execute("Fred", "Wasup", 25000, 60,
null));
System.out.println("Passing needed parameters and interest rate ,
using default term");
System.out.println(loanCreator.execute("Fred", "Wasup", 25000,
null, 3.3));
}
}
Please find the answer below:-
Loan.java
Person.java
LoanCreator.java
LoanCreatorApp.java
Output :-
Thanks.
Hope you like the answer.
Get Answers For Free
Most questions answered within 1 hours.