Homework problem...
[Code Java]
import java.util.Scanner;
public class Prog3{
public static void main(String[] args) {
//intiate the Scanner
Scanner input = new Scanner(System.in);
//decalre loan amount
System.out.print("Enter Loan Amount: ");
double loanAmount = input.nextDouble();
//declare int NumOfYears
System.out.print("Number Of Years: ");
int NumOfYears = input.nextInt();
//declare annual interest rate
double AnnualInterestRate = 5; // intital
System.out.println("Interest Rate: \t Monthly Rate:\t Total Payment: \t");
//intial loop
while (AnnualInterestRate <= 8) //test
{
//Monthly
double MonthlyInterestRate = AnnualInterestRate/1200;
//Calculate monthly payment
double monthlyPayment = loanAmount * MonthlyInterestRate / (1 - (Math.pow(1 / (1 + MonthlyInterestRate), NumOfYears * 12)));
//calculate total payment
double totalPayment = monthlyPayment * 12 * NumOfYears;
//ouput of total, monthly, annual
System.out.print("Interest Rate: \t" + AnnualInterestRate + (" Monthly Rate: \t") + monthlyPayment + " Total Payment: \t" + totalPayment);
System.out.println();
// change
AnnualInterestRate += .125;
} //while
}//main
}// class
[/CODE]
I need to format to a few decimal places, but seriously just am not understanding how to format correctly. It's in a column of 3
Help please.