CODE
class mort {
public static void main(String arg[]) throws IOException
{
BufferedReader stdin =
new BufferedReader ( new InputStreamReader (System.in));
DecimalFormat twoDigitsPastPoint = new DecimalFormat("0.00");
String get_Balance,get_Annual,get_Payment;
int J, Month;
double Annual_Rate=0.00, Balance=0.00, Interest=0.00;
double Payment=0.00, Monthly_Rate=0.00;
System.out.print("\t ==MORTGAGE SOLVER VERSION 1.0==");
System.out.print("\n\n");
System.out.print("WHAT IS THE CURRENT MORTGAGE BALANCE? :=> $ ");
get_Balance = stdin.readLine();
Balance = Double.parseDouble(get_Balance);
System.out.print("WHAT IS THE ANNUAL INTEREST RATE? :=> % ");
get_Annual= stdin.readLine();
Annual_Rate = Double.parseDouble(get_Annual);
System.out.print("WHAT IS THE MONTHLY PAYMENT? :=> $ ");
get_Payment= stdin.readLine();
Payment = Double.parseDouble(get_Payment);
// Computation Routine
Monthly_Rate = (Annual_Rate / 12.0);
Monthly_Rate = (0.01 * Monthly_Rate);
System.out.print("\n");
System.out.print("\tTHE NEXT 12 MONTHS ");
System.out.print("\n");
System.out.print(" MONTH INTEREST BALANCE\n");
for (J=1; J<=33; J++) {
System.out.print("-");
}
System.out.print("\n\n");
for (Month=1; Month<=12; Month++) {
Interest = (Monthly_Rate * Balance);
Balance += Interest - Payment;
System.out.println(Month + " " + twoDigitsPastPoint.format(Interest)
+ "" + twoDigitsPastPoint.format(Balance));
}
System.out.print(" === END OF COMPUTATION === ");
}
} // END OF CODE