The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Design, write in Java, test and document a program that computes the monthly payment and the total payment for a bank loan. The program lets the user enter the loan amount (a floating point value of type double), the loan period (an integer) in number of years, and a range of annual interest rates (two floating point values). The program displays the monthly and total payments for each interest rate within the given range, with an increment of 1/4. For example, if the user enters the loan amount 10000 for five years, with interest rates 5.00% and 8.00%, the program should display a table as follows:
Loan Amount: 10000
Number of Years: 5
|
Interest Rate |
Monthly Payment |
Total Payment |
|
5.00% |
188.71 |
11322.74 |
| 5.25% | 189.85 |
11391.59 |
| ....... | ............ | ........... |
|
7.75% |
201.56 |
12094.17 |
|
8.00% |
202.76 |
12165.83 |
| Â | Â | Â |
Â
The monthly and total repayments are to be displayed correct to two decimal places. The input data is to be validated. If the user enters a zero or negative value, the program should output an appropriate error message and re-prompt for input until the user enters the correct data. Also, be sure to adjust the interest rate for the monthly period. For example, when annual interest rate is 5 percent, then when posting monthly interest rate, you use 5/12 percent. The formula to compute the monthly payment is as follows: monthlyPayment = (loanAmount x monthlyInterestRate) / (1 – (1 / (1 + monthlyInterestRate)numberOfYears x 12 ))
In the above formula, you have to compute (1 + monthlyInterestRate)numberOfYears x 12 ). The pow(a,b) method in the Java API Math class can be used to compute a b.
The program should loop around and allow the user to repeat the above calculations for another set of input data until the user does not want to continue. The program should be well-structured and should have a reasonable set of methods in addition to the main method. It should use a good coding style, proper indentation, meaningful identifier names and appropriate comments throughout.Â
-----------