You have just purchased a stereo system that cost $1000.00 on the following cred
ID: 3847320 • Letter: Y
Question
You have just purchased a stereo system that cost $1000.00 on the following credit plan: no down payment, an interest rate of 18% per year, and monthly payments of $50. The monthly payment of $50 is used to pay the interest, and whatever is left is used to pay part of the remaining debt. Hence, the first month you pay 1.5% of $1000.00 in interest. That is $15.00 in interest. The remaining $35 is deducted from your debt, which leaves you with $965.00. The next month you pay interest of 1.5% of $965.00, which is $14.48. Hence, you can deduct $35.52 from the amount you owe.
Write a Java program that will tell you how many months it will take you to pay off 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. Use a variable to count the number of loop iterations and hence the number of months until the debt is zero. You may want use other variables as well. The last payment may be less than $50.00 if the debt is small, but do not forget the interest. If you owe $50.00, then your monthly payment of $50.00 will not pay off your debt, although it will come close. One month’s interest on $50.00 is only $0.75.
Submit a copy of your program,
Requirements:
•(10 pts) Fully document
•(15 pts) Write a working program
• (10 pts) Use proper data types, variable names, and only two decimal digits after the period at every step.
• (5 pts) Format your code
• (10 pts) Test your program and make sure the output is formatted, and readable
Explanation / Answer
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
class Loan
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
System.out.println(" Enter the Loan Amount: $");
double principal = scan.nextDouble();
System.out.println(" Enter the Monthly Payment: ");
double interest_rate = scan.nextDouble();
System.out.println(" Enter the Interet Rate: ");
double rate = scan.nextDouble() / 100.0;
double total_payment = 0;
int month = 0;
while(principal > 0)
{
interest_rate = principal * 0.015;
double pay = 50 - interest_rate;
principal = principal - pay;
month = month + 1;
total_payment = total_payment + interest_rate;
}
System.out.println(" Months to pay off loan = " +month);
System.out.println(" Total Interest to be paid = " +total_payment);
}
}
OUTPUT
Enter the Loan Amount: $1000
Enter the Monthly Payment: 50
Enter the Interet Rate: 18
Months to pay off loan = 24
Total Interest to be paid = 197.82677216560813
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.