You have just purchased a stereo system that cost c on the following credit plan
ID: 645420 • Letter: Y
Question
You have just purchased a stereo system that cost c on the following
credit plan: no down payment, an interest rate of r% per year ( r
12:0% per
month), and monthly payments of p. The monthly payment of p is used to
pay the interest, and whatever is left is used to pay part of the remaining
debt. Hence, the rst month you pay r
12:0% of c in interest. What is not
interest is deducted from your debt. The next month you repeat this process,
continuing until the debt is paid o
.
Write a program that will tell you how many months it will take you to pay
o
the loan, as well as the total amount of interest paid over the life of the
loan. Use a loop to calculate the amount of interest and the size of the debt
after each month. Your program should also print the month number, the
monthly amount of interest paid and the remaining debt for each month.
Use a variable to count the number of loop iterations and hence the number
of months until the debt is zero.
You will need to prompt the user for the amount of the loan, the annual
interest rate as a percentage (18 should be the input and you will have to
convert it to 0:18) and the amount that you will be paying each month.
Input Validation: Display an error message prompt the user additional times
if the user enters any values that are not greater than zero.
Your program must also include comments with your name, the date, and
a short description of the project. It must also print this information as a
splash screen at the beginning of the program run. All output should be
properly formatted and aligned.
Explanation / Answer
public class CompoundInterest { public static void main( String args[] ) { double principal = 10000; int years = 5; double rate = .05; System.out.printf("Principle: %.2f ", principal); System.out.println("Years: " + years); System.out.println("Interest rate: " + rate); System.out.println("Total amount componded over the " + years + " years:" ); for(int x = 1; xRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.