Write a program that lets the user enter the loan amount and loan period in number of
Question:
Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 5% to 8%, with an increment of 1/8. Here is a sample run:
For the formula to compute monthly payment, see Listing 2.9, ComputeLoan.java.
Transcribed Image Text:
Loan Amount: 10000 -Enter Number of Years: 5 PEnter Interest Rate Total Payment 11322.74 11357.13 11391.59 Monthly Payment 188.71 189.29 189.86 5.000% 5.125% 5.250% ... 202.17 202.76 12129.97 12165.84 7.875% 8.000% 1 import java.util.Scanner; 2 3 public class ComputeLoan { public static void main(String[] args) { // Create a Scanner Scanner input = new Scanner(System.in); 4 5 // Enter annual interest rate in percentage, e.g., 7.25% System.out.print("Enter annual interest rate, e.g., 7.25%: "); double annualInterestRate = input.nextDouble(); 10 11 12 13 14 15 16 17 18 19 20 21 22 // Obtain monthly interest rate double monthlyInterestRate =- annualInterestRate / 1200; // Enter number of years System.out.print( "Enter number of years as an integer, e.g., 5: "); int numberOfYears - input.nextInt(); // Enter loan amount System.out.print("Enter loan amount, e.g., 120000.95: "); double loanAmount = input.nextDouble(); 23 // Calculate payment double monthlyPayment = loanAmount * monthlyInterestRate / (1 - 1 / Math.pow(1 + monthlyInterestRate, numberofYears * 12)); 24 25 26 27 double totalPayment = monthlyPayment * numberoffYears * 12; 28 // Display results System.out.println("The monthly payment is S" + (int) (monthlyPayment * 100) / 100.0); System.out.println("The total payment is S" + (int)(totalPayment * 100) / 100.0); 29 30 31 32 33 34 35 }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 58% (12 reviews)
Program plan Crate class called ComputeLoan Declare variables of type double loanAmount ...View the full answer
Answered By
Ehsan Mahmood
I’ve earned Masters Degree in Business Studies and specialized in Accounts & Finance. Couple with this, I have earned BS Sociology from renowned institute of Pakistan. Moreover, I have humongous teaching experience at Graduate and Post-graduate level to Business and humanities students along with more than 7 years of teaching experience to my foreign students Online. I’m also professional writer and write for numerous academic journals pertaining to educational institutes periodically.
4.90+
248+ Reviews
287+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
The monthly payment for a given loan pays the principal and the interest. The monthly interest is computed by multiplying the monthly interest rate and the balance (the remaining principal). The...
-
Exercise to display all solutions for the Sudoku game, as shown in Figure. When you click the?Solve?button, the program stores all solutions in an?ArrayList. Each element in the list is a...
-
The complete solution for the Sudoku problem is given in Supplement VI.C. Write a program that lets the user enter the input from the text fields, as shown in Figure 22.15a. Clicking the Solve button...
-
Write a program Tree that takes a command-line argument n and produces the following recursive patterns for n equal to 1, 2, 3, 4, and 8. So b b b h l 4 3 2 1
-
Find the domain and range of these functions. Note that in each case, to find the domain, determine the set of elements assigned values by the function. a) The function that assigns to each bit...
-
Consider the statement Organizations need people, and people need organizations. Is this assertion true for all types of organizations? Give examples of where it is and where it probably isnt true.....
-
What is a debenture? Why might DuPont be able to issue debentures frequently, while Jones Airlines, Inc., a less dependable business, might not?
-
The Euro Watch Company assembles expensive wristwatches and then sells them to retailers throughout Europe. The watches are assembled at a plant with two assembly lines. These lines are intended to...
-
undefined E6-37A (similar to) Question Help Craig Carriage Company offers guided horse-drawn carriage rides through historic Columbus, Georgia. The carriage business is highly regulated by the city....
-
Using α = 0.05, perform a hypothesis test with the data from Problem 18.35 to determine if the population rank correlation coefficient is less than zero. From Problem Variable 4 72 6 6...
-
A cancellation error occurs when you are manipulating a very large number with a very small number. The large number may cancel out the smaller number. For example, the result of 100000000.0 +...
-
Modify Listing 5.15 to display all the prime numbers between 2 and 1,000, inclusive. Display eight prime numbers per line. Numbers are separated by exactly one space. Listing 5.15 1 public class...
-
Generic Inc. is a distributor of pharmaceutical products. Its ABC system has five activities: Activity Area Cost Driver Rate in 2018 1. Order processing S40 per order 2. Line-item ordering 3 per line...
-
Assume you have been given $400,000 CAD with access to all listed stocks, bonds, futures, and options worldwide. You can trade in options and futures, in combination with the underlying asset....
-
The formula weight (FW) of a gas can be determined using the following form of the ideal gas law FW = g R T / PV where g is the mass in grams, R is the gas constant, T is the temperature in Kelvin, P...
-
Consider a game in which a fair die is thrown. The player pays $5 to play and wins $2 for each dot that appears on the roll. Define X = number on which the die lands, and Y = player's net profit...
-
2. Getting ready for Logarithms and Calculus! a. Fill in the chart and graph the function (I advise practicing on your scientific calculator and desmos. X f(x) = Inx 0 0.5 1 e 10...
-
JoJo Co. had the following balances and information for October. Beg. finished goods inventory = $30 Beg. work in process inventory = $5 Beg. raw materials inventory = $15 End. finished goods...
-
Paulas boyfriend moved to her home town, Oklahoma City, from Houston, Texas. Two weeks after he arrived, he asked her to phone his bank in Houston and inquire about his balance. She did so as a favor...
-
Sandcastles, Inc.s management has recently been looking at a proposal to purchase a new brick molding machine. With the new machine, the company would not have to buy bricks. The estimated useful...
-
You can use the ____________ statement to terminate a switch statement. a. switch b. break c. case d. end
-
Which of the following cannot be the argument tested in a switch statement? a. int b. char c. double d. String
-
Assuming a variable w has been assigned the value 15, what does the following statement do? w == 15 ? x = 2 : x = 0; a. Assigns 15 to w b. Assigns 2 to x c. Assigns 0 to x d. Nothing
-
Suppose B=(2,2,1). Suppose Also That B Makes An Angle Of 30 Degrees With A And AxB=6. Find A
-
..
-
true- false statement (1) Present value is additive. G) Publie firms smooth dividends to satisfy shareholders' consumption preferences
Study smarter with the SolutionInn App