Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java: Write a program that computes the monthly loan payment, given the loan amount (a double value), the interest, as a percent % (a double

Java: Write a program that computes the monthly loan payment, given the loan amount (a double value), the interest, as a percent % (a double value), and the number of years to repay the loan (an int value). The calculation is to be performed in a method that is called from main(). In main(), the calling method, you are to solicit the following values: 1. Loan amount, which is used for all calculations 2. The starting number of years to repay the loan, ending number of years to repay the loan, and the incremental years. 3. The starting interest rate, as a %, the ending interest rate, as a %, and the incremental interest rate, as a %. You will the use for loops to create tables of monthly payments based on the number of years to repay the loan, the table containing interest rate and the monthly loan payment. The outer for loop will start with the starting number of years, continuing until the ending year is reached or exceeded, incrementing then number of years each time through the loop by the specified number of incremental year. For each year selected, display the number of years, then follow with a table of monthly payments using interest rates starting at the starting interest rate, continuing until the ending interest rate is met or exceeded, incrementing the interest rate by the specified incremental interest. The table will thus contain two labeled columns, interest rate and monthly payment. Refer to Textbook Example Mortgage.java for soliciting User inputs and performing the monthly payment calculation. Sample Run for Problem 2 Enter the loan amount: 275000 Enter the starting number of years to repay the loan: 10 Enter the ending number of years to repay the loan: 20 Enter the years increment between tables: 5 Enter the starting loan yearly interest rate, %: 6.25 Enter the ending loan yearly interest rate, %: 7.25 Enter the increment interest rate, %: 0.5 Principle: $275000.0 Years to repay: 10 Interest Monthly Rate Payment -------- ------- 6.25 3087.7 6.75 3157.66 7.25 3228.53 Principle: $275000.0 Years to repay: 15 Interest Monthly Rate Payment -------- ------- 6.25 2357.91 6.75 2433.5 7.25 2510.37 Principle: $275000.0 Years to repay: 20 Interest Monthly Rate Payment -------- ------- 6.25 2010.05 6.75 2091.0 7.25 2173.53 Book's example: import java.util.*; public class Page169 { public static void main(String[] args){ Scanner console = new Scanner (System.in); System.out.println("This program computes monthly " + "mortgage payments."); System.out.print("loan amount : "); double loan = console.nextDouble(); System.out.print("number of years : "); int years = console.nextInt(); System.out.print("interest rate : "); double rate = console.nextDouble(); System.out.println(); int n = 12 * years; double c = rate / 12.0 / 100.0; double payment = loan * c * Math.pow(1 + c, n) / (Math.pow(1 +c, n) - 1); System.out.println("payment = $" + (int) payment); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions