I can get it to enter amount and also enter rate and enter amount of years but can't get it to tell me the monthly payment for some reason. I know I am missing something.
import java.util.Scanner; public class project5{ /** * @param args */ public static void main(String[] args) { //Print out the welcome screen System.out.println ("Welcome to the Loan Calculator"); System.out.println(); double loanAmount; double interestRate; double months = 0; String choice = ("y"); double numberYears; while (choice.equalsIgnoreCase("y")) { //read loan amount Scanner sc = new Scanner (System.in); System.out.print("enter amount"); loanAmount = sc.nextDouble(); //read interest rate System.out.print("enter interest rate"); interestRate = sc.nextDouble(); //read number of years System.out.print("enter number of years"); numberYears = sc.nextDouble(); //calculate the monthly payment double monthlyPayment = loanAmount * interestRate / (1 - 1/Math.pow(1 + interestRate, months)); //display the monthly payment System.out.println ("The monthly payment is:"); //see if the user wants to continue System.out.print("continue? (y/n): "); choice = sc.next(); System.out.println(); } } }