Here are some examples of how your program should behave. Please use the exact same test cases as these, so that I can verify that your program works:
** Welcome to the Consumer Loan Calculator ** How much do you want to borrow? $1000 What is the annual interest rate expressed as a percent? 18 What is the monthly payment amount? $50 Your debt will be paid off after 24 months, with a final payment of just $47.83 The total amount of interest you will pay during that time is $197.83 ** Don't get overwhelmed with debt! ** ** Welcome to the Consumer Loan Calculator ** How much do you want to borrow? $15000 What is the annual interest rate expressed as a percent? 10 What is the monthly payment amount? $100 You must make payments of at least $126.00 Because your monthly interest is $125.00 ** Don't get overwhelmed with debt! ** ** Welcome to the Consumer Loan Calculator ** How much do you want to borrow? $-50 You must enter a positive number How much do you want to borrow? $-200 You must enter a positive number How much do you want to borrow? $20000 What is the annual interest rate expressed as a percent? -2.5 You must enter a positive number What is the annual interest rate expressed as a percent? 5 What is the monthly payment amount? $0 You must enter a positive number What is the monthly payment amount? $200 Your debt will be paid off after 130 months, with a final payment of just $125.79 The total amount of interest you will pay during that time is $5,925.79 ** Don't get overwhelmed with debt! **
static double getPosNumber(String prompt) // This function outputs the prompt to the console, reads input // from the console, and converts it to a number, // which the function returns. If the number is not positive, // the user is told to enter a new number until a positive number is entered. static void payOffLoan(double principle, double rate, double payment) /* This function assumes the payment is enough to cover first month's interest. It has a loop to pay off the loan one month at a time. It outputs to the console: - how many months it will take to pay off the loan - total amount of interest paid during that time - amount of final payment */
Month 1:
$100 * 0.01 = $1 interest for the month
adding interest and subtracting the payment:
$100 + $1 - $50 = $51 new balance
Month 2:
$51 * 0.01 = $0.51 interest for the month
adding interest and subtracting the payment:
$51 + $0.51 - $50 = $1.51 new balance
Month 3:
$1.51 * 0.01 = $0.02 interest for the month (you don't have to round in your calculations)
adding interest and subtracting the payment:
$1.51 + $0.02 - $50 = -$48.47 new balance
Since the new balance is negative, the loan is paid off, and the final payment is too much. It should have been $50 - $48.47 = $1.53 final payment.