import javax.swing.*; // Needed for JOpionPane
public class AcmeBankFINAL {
public static void main(String[] args) {
int numYrs = 0;
int age;
double loanAmount = 0.0;
double anuInRate = 0.0;
double loanTotal;
double intRepay;
double repayFactor;
double totPayTime;
double totalPayTime;
double discount;
double existAccDis = 0;
double repaymentFactor = 0;
boolean ozCitzen = true;
boolean existAcc = false;
String repaymentMethod = "monthly";
//Input LoanAmount, Annual Interest Rate, Number of Years, existing Account,Australian Citzen, Age
loanAmount = Double.parseDouble(JOptionPane.showInputDialog("Requested Loan Amount"));
anuInRate = Double.parseDouble(JOptionPane.showInputDialog("Annual Interest rate"));
numYrs = Integer.parseInt(JOptionPane.showInputDialog("Number of years over which the loan will be paid in"));
repaymentMethod = JOptionPane.showInputDialog("Replayment method, either 'quarterly', 'monthly' or 'fortnightly'");
existAcc = Boolean.valueOf(JOptionPane.showInputDialog("Do you have an existing account, 'true' or 'false'"));
ozCitzen = JOptionPane.showInputDialog("Do you have an existing account, 'true' or 'false'");
age = Integer.parseInt(JOptionPane.showInputDialog("How old are you? In Number format"));
//Special Characteristics for existing Account, Australian Citzen and Their Age
//Discount is the 0.5% of the Annual Interest Rate
String Answer;
double discount;
Answer = JOptionPane.showInputDialog("Do you have an existing account, 'true' or 'false'");
if (Boolean.parseBoolean(Answer))
{
discount = 0.5;
JOptionPane.showMessageDialog(null, "Discount = " + discount);
}
else
{
discount = 0;
JOptionPane.showMessageDialog(null, "Discount = " + discount);
}
Answer = JOptionPane.showInputDialog("Are you an Australian Citzen, 'true' or 'false'");
if (!Boolean.parseBoolean(Answer))
JOptionPane.showMessageDialog(null, "Citzen: you can not continue if your not Australian");
}
}
//Loan Total Calc RETURN
loanTotal = totLoanCalc(loanAmount, anuInRate, numYrs);
intRepay = intRepay(loanAmount, loanTotal);
existAccDis = existAccDis(anuInRate, discount, loanTotal);
if (repaymentMethod.equals("monthly")) {
repaymentFactor = 12;
} else if (repaymentMethod.equals("quarterly")) {
repaymentFactor = 4;
} else if (repaymentMethod.equals("fortnightly")) {
repaymentFactor = 26;
}
//The Total Repayment of Years and Repayment either Monthly, Quarterly, fortnightly
totPayTime = totPayTime(numYrs, repaymentFactor);
//Results
JOptionPane.showMessageDialog(null, "Your Total Loan Repayment is" + " " + "$" +loanTotal);
JOptionPane.showMessageDialog(null, "Your Total Loan Repayment is" + " " + "$" +intRepay);
JOptionPane.showMessageDialog(null, "Your Total Repayment Period is" + " " +totPayTime);
JOptionPane.showMessageDialog(null, "Loan Total with or without Discount" + " " + "$" +existAccDis);
}
public static double totLoanCalc(double loanAmount, double anuInRate, int numYrs){
return loanAmount * (1 + anuInRate / 100 * numYrs);
}
//Amount Of Interest Paid
public static double intRepay(double loanAmount, double loanTotal){
return loanTotal - loanAmount;
}
//Repayment Period
public static double totPayTime(int numYrs, double payFactor) {
return numYrs * payFactor;
}
//Existing Account Discount
public static double existAccDis(double anuInRate, double discount, double loanTotal) {
return loanTotal - (1+ anuInRate / 100 * discount);
}
}