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: 54% (11 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...
-
In which situation shown in Figure 24.23 will the electromagnetic wave be more successful in inducing a current in the wire? Explain. E (a) B (b) E
-
If the interest rate at B is 20 percent, then which of the following best describes the analysis of the investment? a. The IRR of the investment is less than 20 percent. b. The IRR of the investment...
-
Diamondback Welding & Fabrication Corporation sells and services pipe welding equipment in Illinois. The following selected accounts appear in the ledger of Diamondback Welding & Fabrication...
-
A cylindrical silo topped by a hemispherical vault of 1920 m3 was built. The production cost per m2 is double in the vault than in the cylindrical part. The cost is $8000 pesos per m2 in the vault If...
-
On September 2, 2010, the Securities & Exchange Commission brought an action against Sujata Sachdeva, vice president of finance, and Koss senior accountant and subordinate, Julie Mulvaney, who...
-
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...
-
How can Brad Smiths effectiveness as CEO of Intuit be explained from a transformational leadership theory perspective?
-
Two airlines are competing against each other. Both raise prices at the same time and the market outcome is such that profits rise for both. Is this sufficient evidence that the two firms are...
-
Give a real or fictitious example of a trade secret. What would be considered a theft of this trade secret? What should an owner of a business do to protect trade secrets? To win a lawsuit to protect...
-
Describe the organization for a local pizzeria. Then, suggest the best approach for its marketing organization design, keeping in mind the need to be flexible in order to meet the challenges of...
-
Proxy Computing Co. has the following costs: TC = 256 + 128Q + 8Q2 (i) Identify the fixed, variable and marginal costs. Does the cost structure represent a short-run or long-run cost structure? Why?...
-
Short-tail keywords suggest that customers are harder to convert, they are still browsing, not as ready to commit, and maybe not as knowledgeable about your brand or product. Explain why this...
-
As part of the analytical procedures of Mahogany Products Ltd, you perform calculations of the following ratios: REQUIRED For each of the preceding ratios: a. State whether there is a need to...
-
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
-
What does Rafe represent to Elsa on the night they meet? Is it simply sex and loneliness? Or do you think there's something deeper involved? Another small defiance against her parents'...
-
Do all 6 questions. Each question is worth 10 marks, for a total of 60 available marks. The test is worth 40% of your course grade Question 1 ( 10 marks total) Elasticity, Competition versus...
-
Plant-based meat alternatives are on the rise as consumers become more health and environmentally conscious. Using the demand and supply analysis, how does this trend impact the meat industry in the...
Study smarter with the SolutionInn App