Question

Using the Prelude to Programming book, complete Programming Challenge 5 on page 178.

Solve using Raptor. Kim wants to buy a car. Help Kim compute the monthly payment on a loan, given the loan amount, the annual percentage rate of interest, and the number of monthly payments. The program should allow Kim to input the loan amount, interest rate, and how many payments she wants to make. It should then compute and display the monthly payment.

                   

You will need the following variables:

                   

		Payment        LoanAmt         InterestRate
		MonthlyRate    NumberMonths

                   

You will need the following formulas:

                   

		MonthlyRate = InterestRate/1200

                   

Note: when the user enters InterestRate as a percentage, it must be divided by 100 to make it a decimal (i.e., 18% = 18/100 = 0.18). The InterestRate offered by car dealers is an annual rate so this must be divided by 12 to get the MonthlyRate. The formula given above combines the two steps (i.e., annual rate of 18% = 18/100 = 0.18 and the monthly rate is 0.18/12 = 0.015 or 18/(100*12) = 18/1200.

                   

		Payment = LoanAmt * MonthlyRate * (1 + 
		           MonthlyRate)^NumberMonths ÷ ((1 +
		           MonthlyRate)^NumberMonths – 1)

                   

Note: The formula must be entered carefully, exactly as shown.


0 0
Add a comment Improve this question Transcribed image text
Answer #1
/************************************BuyCar.java********************************/
import java.text.DecimalFormat;
import java.util.Scanner;
public class BuyCar {
   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       DecimalFormat f = new DecimalFormat("#.##");
       System.out.print("Enter the loan amount:");
       double loanAmount = scan.nextDouble();
       System.out.print("Enter the interest rate: ");
       double interestRate = scan.nextDouble();
       System.out.print("How many payment you want to make: ");
       int numberOfPayment = scan.nextInt();
       double monthlyRate = interestRate / 1200;
       // This is your formula
       double payment1 = (loanAmount * monthlyRate)
               * (Math.pow((1 + monthlyRate), numberOfPayment) / (Math.pow(1 + monthlyRate, numberOfPayment) - 1));
       // The same formula you can use
       double payment = (loanAmount * monthlyRate) / (1 - Math.pow(1 + monthlyRate, -numberOfPayment));
       System.out.println("Each month payment is: " + f.format(payment));
       System.out.println("Each month payment by your formula: " + f.format(payment1));
   }
}

/**********************output*****************************/

Enter the loan amount:20000
Enter the interest rate: 8
How many payment you want to make: 12
Each month payment is: 1739.77
Each month payment by your formula: 1739.77


answered by: javaeye
Add a comment
Know the answer?
Add Answer to:
Using the Prelude to Programming book, complete Programming Challenge 5 on page 178.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SVED120

    solve using Raptor. Kim wants to buy a car. Help Kim compute the monthly payment on a loan, given the loan amount, the annual percentage rate of interest, and the number of monthly payments. The program should allow Kim to input the loan amount, interest rate, and how many payments she wants to make. It should then compute and display the monthly payment.                   You will need the following variables:       ...

  • IT MUST USE PHP AND HTML IT CANT BE JAVASCRIPT IT HAS TO BE PHP AND...

    IT MUST USE PHP AND HTML IT CANT BE JAVASCRIPT IT HAS TO BE PHP AND HTML Using PHP and HTML 5, create a webpage that calculates the monthly payment for a car loan. The user enters the price of the car (P), down payment (D), Annual Percentage Rate (R), and the number of years (N). Compute the monthly payment (M) using the following formula and display it: Let i = R / 1200 and n = N * 12;...

  • Give the project a meaningful name. Write a main method to test a new static method...

    Give the project a meaningful name. Write a main method to test a new static method used to compute a monthly payment on a loan. The new static method used to compute the monthly payment for a loan uses this formula: m = p_0 middot r middot (1 + r)^n ((1 + r)^n - 1) Where m is the monthly payment, P_0 is the initial loan amount, r is the monthly interest rate, and n is the number of monthly...

  • using Matlab program: Create a loan payment program that can be used for any loan amount...

    using Matlab program: Create a loan payment program that can be used for any loan amount such as a home or car loan. The program should ask the user for the input values below, compute the monthly payment, then compute the monthly balance. Display the balance in a table Month             Balance 1                      $ ##.## 2                      $ ##.## 3                      $ ##.##       . . . etc Use the formula PMT=P*(r(1+r)^n)/((1+r)^n-1) PMT = the monthly payment. P = the principal r = the interest rate per month, which...

  • Program Specification: This project involves implementing a Java program that performs a calculation of payments associated...

    Program Specification: This project involves implementing a Java program that performs a calculation of payments associated with loans. The program shall allow a user to enter the following data: annual interest rate the loan (i.e. , number of years), and the loan amount. A GUI like the one below must be used. Loan Calculator Annual Interest Rate: Number of Years Loan Amount: Monthly Payment Total Payment Calculate When the user presses the calculate button, the monthly payment and total amount...

  • Consider the following loan. Complete parts (a)-(c) below An individual borrowed $73,000 at an APR of 7 % , which w...

    Consider the following loan. Complete parts (a)-(c) below An individual borrowed $73,000 at an APR of 7 % , which will be paid off with monthly payments of $595 for 18 years. a. Identify the amount borrowed, the annual interest rate, the number of payments per year, the loan term, and the payment amount. The amount borrowed is $ the annual interest rate is the number of payments per year is the loan term is years, and the payment amount...

  • answer those 4 please Fatima just borrowed 83,364 dollars. She plans to repay this loan by...

    answer those 4 please Fatima just borrowed 83,364 dollars. She plans to repay this loan by making a special payment of 29,387 dollars in 7 years and by making regular annual payments of 13,147 dollars per year until the loan is paid off. If the interest rate on the loan is 17.93 percent per year and she makes her first regular annual payment of 13,147 dollars immediately, then how many regular annual payments of 13,147 dollars must Fatima make? Round...

  • 13-19 odd please 13. A $10,000 loan is to be amortized for 10 years with quarterly...

    13-19 odd please 13. A $10,000 loan is to be amortized for 10 years with quarterly payments of $334.27. If the interest rate is 6% compounded quarterly, what is the unpaid balance immediately after the sixth payment? 14. A debt of $8000 is to be amortized with 8 equal semi- annual payments of $1288.29. If the interest rate is 12% compounded semiannually, find the unpaid balance immediately after the fifth payment. 15. When Maria Acosta bought a car 2 years...

  • American School Business Math Exam 2 Business Math Exam 2 Student Number Student Name table on...

    American School Business Math Exam 2 Business Math Exam 2 Student Number Student Name table on page A13 n the textbo etfer to the Monthly Payment on an Installment Loan of sio0 table on page A13 in the textbook. 16. Antoni Gaudi monthly payments, what $2.650. The store financing requires a l5% down payment and 42 monthly payments. What is the finance chargse? purchased a bedroom set with an installment loan that has an APR of 12%. 17. Louise Bourgeois...

  • Please answer the following questions using the information below. Use the following rates for answering questions...

    Please answer the following questions using the information below. Use the following rates for answering questions A.Bank of America interest rate of 2.99% B. Des Moines Metro Credit Union interest rate of 3.02% You are considering purchasing a new car and you want to do some financial research first. a) Determine the best interest rate for a new car purchase for a 48- month loan at a bank near you. If you finance a $25,999 with such a loan, determine...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT