I cannot get this correct to show 3 types of loan payments.
and to have user input to show the next 20 or so lines in DOS command prompt
import java.lang.Math.*;
import java.text.*;
import java.io.*;
public class prt1fixtry (double principle, double rate, int no_yrs)
{
principal = prin;
annualInterest = rate/100; // convert rate
years = no_yrs;
}
// (Main) method that will display all of the output.
public static void main(String[] args)
double principal = 200000.0; // same principal amount.
{
// Define the variables to be used
MortgageProgram payment1 = new MortgageProgram(principal, 5.35, 7);
MortgageProgram payment2 = new MortgageProgram(principal, 5.5, 15);
MortgageProgram payment3 = new MortgageProgram(principal, 5.75, 30);
payment1.print();
payment2.print();
payment3.print();
// Array Size
int size = rateArray.length - 1;
// Correct and proper Currency Format
DecimalFormat decimalAmount = new DecimalFormat("#,##0.00");
// Variables used for calculating Mortgage
System.out.println();
System.out.println("\t\t\t\tMortgage Calculator\n");
System.out.println("Principle: \t$" + decimalAmount.format(principle));
System.out.println();
System.out.println("Term\t \tRate\t\tPayment");
for (i=size; i>=0; i--)
{
// Payment method, principle, terms and the interest rate array.
payment = CalculatePayment(principle, termArray, rateArray);
// Should display payment, rate and the amount in the current mortgage.
System.out.println(termArray/12 + " \t\t" + 100 * rateArray + "%\t\t$" + decimalAmount.format(payment));
}
Systecdm.out.println();
}
// Used to calculate the amound in the payment based on the principle, the term and the interest rate.
public static double CalculatePayment(double principle, int term, double rate)
{
//Returns the amount of the mortgage and does all the fancy work for the user behind the scenes in the meanwhile exiting quietly.
return(principle * Math.pow(1+(rate/12), term) * rate/12) / (Math.pow(1 + rate/12, term) - 1);
}
}
.
This needs to be Java code ran in a command prompt.
and to have user input to show the next 20 or so lines in DOS command prompt
import java.lang.Math.*;
import java.text.*;
import java.io.*;
public class prt1fixtry (double principle, double rate, int no_yrs)
{
principal = prin;
annualInterest = rate/100; // convert rate
years = no_yrs;
}
// (Main) method that will display all of the output.
public static void main(String[] args)
double principal = 200000.0; // same principal amount.
{
// Define the variables to be used
MortgageProgram payment1 = new MortgageProgram(principal, 5.35, 7);
MortgageProgram payment2 = new MortgageProgram(principal, 5.5, 15);
MortgageProgram payment3 = new MortgageProgram(principal, 5.75, 30);
payment1.print();
payment2.print();
payment3.print();
// Array Size
int size = rateArray.length - 1;
// Correct and proper Currency Format
DecimalFormat decimalAmount = new DecimalFormat("#,##0.00");
// Variables used for calculating Mortgage
System.out.println();
System.out.println("\t\t\t\tMortgage Calculator\n");
System.out.println("Principle: \t$" + decimalAmount.format(principle));
System.out.println();
System.out.println("Term\t \tRate\t\tPayment");
for (i=size; i>=0; i--)
{
// Payment method, principle, terms and the interest rate array.
payment = CalculatePayment(principle, termArray, rateArray);
// Should display payment, rate and the amount in the current mortgage.
System.out.println(termArray/12 + " \t\t" + 100 * rateArray + "%\t\t$" + decimalAmount.format(payment));
}
Systecdm.out.println();
}
// Used to calculate the amound in the payment based on the principle, the term and the interest rate.
public static double CalculatePayment(double principle, int term, double rate)
{
//Returns the amount of the mortgage and does all the fancy work for the user behind the scenes in the meanwhile exiting quietly.
return(principle * Math.pow(1+(rate/12), term) * rate/12) / (Math.pow(1 + rate/12, term) - 1);
}
}
.
This needs to be Java code ran in a command prompt.