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 existAccDis = 0; boolean ozCitzen = true; boolean existAcc = false; String repaymentMethod = "monthly"; //Store Memory for User input String temp; /**Input LoanAmount, Annual Interest Rate, Number of Years, existing Account,Australian Citzen, Age*/ temp = JOptionPane.showInputDialog("Requested Loan Amount"); loanAmount = Double.parseDouble(temp); temp = JOptionPane.showInputDialog("Annual Interest rate"); anuInRate = Double.parseDouble(temp); temp = JOptionPane.showInputDialog("Number of years over which the loan will be paid in"); numYrs = Integer.parseInt(temp); temp = JOptionPane.showInputDialog("Replayment method, either 'quarterly', 'monthly' or 'fortnightly'"); repaymentMethod = (temp); temp = JOptionPane.showInputDialog("Do you have an existing account, 'true' or 'false'"); existAcc = Boolean.valueOf(temp); temp = JOptionPane.showInputDialog("Are you an Australian Citzen, 'true' or 'false'"); ozCitzen = Boolean.valueOf(temp); temp = JOptionPane.showInputDialog("How old are you? In Number format"); age = Integer.parseInt(temp); /**Special Characteristics for existing Account, Australian Citzen and Their Age*/ double discount; //Discount is the 0.5% of the Annual Interest Rate if(existAcc == true) discount = 0.5; //false they don't get the discount. else discount = 0; if(ozCitzen == false) JOptionPane.showMessageDialog(null, "Citzen: you can not continue if your not Australian"); //false no input else if(age <= 49) { //false } else JOptionPane.showMessageDialog(null, "Age: cannot specify a repayment period of greater than 10 years"); //Loan Total Calc RETURN loanTotal = totLoanCalc(loanAmount, anuInRate, numYrs); intRepay = intRepay(loanAmount, loanTotal); existAccDis = existAccDis(anuInRate, discount, loanTotal); //Replayment Method Calc double repaymentFactor = 0; 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*/ double totalRepayment = numYrs*repaymentFactor; 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){ double totLoanCalc; totLoanCalc = (loanAmount * (1 + anuInRate / 100 * numYrs)); //calc to get Total Loan return totLoanCalc; } //Amount Of Interest Paid public static double intRepay(double loanAmount, double loanTotal){ double intRepay; intRepay = (loanTotal - loanAmount); return intRepay; } //Repayment Period public static double totPayTime(int numYrs, double payFactor) { double totPayTime; totPayTime = (numYrs * payFactor); return totPayTime; } //Existing Account Discount public static double existAccDis(double anuInRate, double discount, double loanTotal) { double existAccDis; existAccDis = (loanTotal - (1+ anuInRate / 100 * discount)); return existAccDis; } }