I am needing to put a pause in between each mortgage calculation and do not know what the C equivalant of getchar() is in Java. Here is the code I have so far, after it is finished with the first mortgage at 30 years I want the user to have to press enter to continue to the next rate. Help is appreciated.
import java.io.*; // java input output package
import java.text.DecimalFormat; // allows placement of decimal
public class MonthlyPayments3c extends Thread //class header with "Thread" for sleep
{
public static void main(String[] args)
{
double Loan, NewBal, MIP;
double Rate, MonthlyInterest, Payments; //double precision variables
//assign values to variables
Loan= 200000; // loan amount
Rate = .0575; //interest rate
MonthlyInterest = Rate / 12; // interest for each month
Payments = Loan * (MonthlyInterest / (1 - Math.pow(1+MonthlyInterest, -360))); //my formula
DecimalFormat twoDigits = new DecimalFormat("$,000.00"); // declares decimal format
MIP= (Loan * Rate) / 12;
NewBal = Loan -(Payments-MIP);
System.out.println("Monthly Payments Interest Paid This Payment Loan Balance");
System.out.println();//my printout provides extra line
System.out.print(" " + twoDigits.format(Payments)); //my printout
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
MIP=(NewBal*Rate)/12;
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
NewBal=NewBal -(Payments-MIP);
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
while (NewBal > 1) //while loop to make computations continue until gets to $200000
{
MIP=(NewBal*Rate)/12;
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
NewBal=NewBal -(Payments-MIP);
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.println(" " + twoDigits.format(Payments)); //my printout
if (NewBal <100000) // tells when this is met to transition to sleep phase
try
{
Thread.sleep (50); //sleep phase needed per change request also states pause is 500 milliseconds
}
catch (InterruptedException e)
{
}
}
if (NewBal <1);
{
double Rate2;
Rate2 = .055; //interest rate
MonthlyInterest = Rate2 / 12; // interest for each month
Payments = Loan * (MonthlyInterest / (1 - Math.pow(1+MonthlyInterest, -180))); //my formula
MIP= (Loan * Rate2) / 12;
NewBal = Loan -(Payments-MIP);
System.out.println("Monthly Payments Interest Paid This Payment Loan Balance");
System.out.println();//my printout provides extra line
System.out.print(" " + twoDigits.format(Payments)); //my printout
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
MIP=(NewBal*Rate)/12;
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
NewBal=NewBal -(Payments-MIP);
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
while (NewBal > 1) //while loop to make computations continue until gets to $200000
{
MIP=(NewBal*Rate)/12;
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
NewBal=NewBal -(Payments-MIP);
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.println(" " + twoDigits.format(Payments)); //my printout
try
{
Thread.sleep (50); //sleep phase needed per change request also states pause is 500 milliseconds
}
catch (InterruptedException e)
{
}
}
if (NewBal <1);
{
double Rate3;
Rate3 = .0535; //interest rate
MonthlyInterest = Rate2 / 12; // interest for each month
Payments = Loan * (MonthlyInterest / (1 - Math.pow(1+MonthlyInterest, -84))); //my formula
MIP= (Loan * Rate3) / 12;
NewBal = Loan -(Payments-MIP);
System.out.println("Monthly Payments Interest Paid This Payment Loan Balance");
System.out.println();//my printout provides extra line
System.out.print(" " + twoDigits.format(Payments)); //my printout
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
MIP=(NewBal*Rate)/12;
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
NewBal=NewBal -(Payments-MIP);
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.print(" " + twoDigits.format(Payments)); //my printout
while (NewBal > 1) //while loop to make computations continue until gets to $200000
{
MIP=(NewBal*Rate)/12;
System.out.print("\t\t\t" + twoDigits.format(MIP));//my printout
NewBal=NewBal -(Payments-MIP);
System.out.println("\t\t\t" + twoDigits.format(NewBal));//my printout
System.out.println(" " + twoDigits.format(Payments)); //my printout
try
{
Thread.sleep (50); //sleep phase needed per change request also states pause is 500 milliseconds
}
catch (InterruptedException e)
{
}
}
}
}
}
}