Code:
```import java.text.*;           //20 May 2008, Revision ...many
import java.io.IOException;

class memortgage     //program class name
{
public static void main(String[] args) throws IOException
{
double amount,moPay,totalInt,principal = 200000; //monthly payment, total interest and principal
double rate [ ] = {.0535, .055, .0575};          //the three interest rates
int [ ] term = {7,15,30};                        //7, 15 and 30 year term loans
int time,ratePlace = 0,i,pmt=1,firstIterate = 0,secondIterate = 0,totalMo=0;
boolean validChoice;
System.in.skip(System.in.available());           //clear the stream for the next entered character
do
{
validChoice = true;
System.out.println("What Choice would you Like\n");
System.out.println("1-Interest rate of 5.35% for 7 years?");       //The interest rate per each 3 loans , per line
System.out.println("2-Interest rate of 5.55% for 15 years?");      //each number is the seletion that a user can select on the keyboard
System.out.println("3-Interest rate of 5.75% for 30 years?");
System.out.println("4-Quit");

if (answer == '1')  //7 yr loan at 5.35%
{
ratePlace = 0;
firstIterate = 4;
secondIterate = 21;
totalMo= 84;
}
else if (answer == '2') //15 yr loan at 5.55%
{
ratePlace = 1;
firstIterate = 9;      //it helps If I have the correct numbers to calcualte as in 9*20 to equal 180...that why I was off -24333.76
secondIterate = 20;    //now it is only of -0.40 cents
totalMo = 180;
}
else if (answer == '3') //30 yr loan at 5.75%
{
ratePlace = 2;
firstIterate = 15;
secondIterate = 24;
totalMo = 360;
}
else if (answer == '4') //exit or quit
{
System.exit(0);
}
else
{
System.in.skip(System.in.available());               //validates choice
System.out.println("Invalid choice, try again.\n\n");
validChoice = false;
}
}while(!validChoice);  //when a valid choice is found calculate the following, ! means not, similar to if(x != 4)

for(int x = 0; x < 25; x++)System.out.println();
amount = (principal + (principal * rate[ratePlace] * term[ratePlace] ));
moPay = (amount / totalMo);
totalInt = (principal * rate[ratePlace] * term[ratePlace]);
DecimalFormat df = new DecimalFormat("0.00");
System.out.println("The Interest on \$" + (df.format(principal) + " at " + rate[ratePlace]*100 +
"% for a term of "+term[ratePlace]+" years is \n" +"\$"+ (df.format(totalInt) +" Dollars\n")));
System.out.println("\nThe total amount of loan plus interest is \$"+(df.format(amount)+" Dollars.\n"));
System.out.println("\nThe Payments spread over "+term[ratePlace]* 12+" months would be \$"+
(df.format (moPay) + " Dollars a month\n\n"));
System.in.skip(System.in.available());
System.out.println("\nWould you like to see a planned payment schedule? y for Yes, or x to Exit");
{
System.out.println((term[ratePlace]*12) + " monthly payments:");
String monthlyPayment = df.format(moPay);
for (int a = 1; a <= firstIterate; a++)
{
System.out.println(" Payment Schedule \n\n ");
System.out.println("Month Payment Balance\n");
for (int b = 1; b <= secondIterate; b++)
{
amount -= Double.parseDouble(monthlyPayment);
System.out.println(""+ pmt++ +"\t"+ monthlyPayment + "\t"+df.format(amount));
}
System.in.skip(System.in.available());