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:

Loan amount, which is used for all calculations

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.

See below for a sample run of the program.

Comment your code to include: (1) File and method header descriptions (Refer to file CS210Template.java located in the Canvas module Course Introduction, and (2) General comments throughout the source code.

Using the Canvas Assignment upload feature, submit a compressed file (*.zip) for each of your project submissions (format: LastnameProject4A.zip and LastnameProject4B.zip) that includes the following files:

Source Code file (*.java) You do not need to include any additional project files.

A short Word summary of your work You are to address the three following topics:

What does or doesn't work and why

Any additional functionality reasons or excuses for missing functionality.

What you learned and what you found difficult or unclear about the problem.

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 

Example from the book :

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_2

Step: 3

blur-text-image_3

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

Explain what sorting is.

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago