For the formula to compute monthly payment, see Listing 2.9, ComputeLoan.java.
**5.22 (Financial application: loan amortization schedule) 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 principal paid for the month is therefore the monthly payment minus the monthly interest. Write a
Note
The balance after the last payment may not be zero. If so, the last payment should be the normal monthly payment plus the final balance.
Hint: Write a loop to display the table. Since the monthly payment is the same for each month, it should be computed before the loop. The balance is initially the loan amount. For each iteration in the loop, compute the interest and principal, and update the balance. The loop may look as follows:
for (i = 1 ; i <= numberOfYears * 12 ; i++) {
interest = monthlyinterestRate * balance;
principal = monthlyPayment - interest;
balance= balance- principal;
System.out.println(i + "\t\t" + interest
+ "\t\t" +principal+ "\t\t" +balance);
}
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Python (3rd Edition)
Modern Database Management (12th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
- Please read the instructions carefully: This is a Java programarrow_forwardPlease read the instructions carefully: This is a Java programarrow_forwardX3: inlTo10 Write a function in Java that implements the following logic: Given a number n, return true if n is in the range 1..10, inclusive. Unless "outsideMode" is true, in which case return true if the number is less or equal to 1, or greater or equal to 10.arrow_forward
- nbm.m//,//arrow_forward7) The ideal gas law allows the calculation of volume of a gas given the pressure(P), amount ofthe gas (n), and the temperature (T). The equation is:V = nRT / PSince we only have used integer arithmetic, all numbers will be integer values with nodecimal points. The constant R is 8.314 and will be specified as (8314/1000). This givesthe same result. Implement the idea gas law program where the user is prompted for andenters values for n, T, and P, and V is calculated and printed out. Be careful toimplement an accurate version of this program. Your program should include a properand useful prompt for input, and print the results in a meaningful mannerarrow_forwardJava:arrow_forward
- 17. Redo Programming Exercise 16 so that the user can also input the cost of producing one liter of milk and the profit on each carton of milk.arrow_forwardThank youarrow_forward*** Complete in Java Program** Use Gambler's Ruin Example Gambler's ruin. Suppose a gambler makes a series of fair $1 bets, starting with $50, and continue to play until she either goes broke or has $250. What are the chances that she will go home with $250, and how many bets might she expect to make before winning or losing? Gambler.java is a simulation that can help answer these questions. It takes three command-line arguments, the initial stake ($50), the goal amount ($250), and the number of times we want to simulate the game. Implement and modify Gambler's ruin simulation from the textbook or textbook website. Modify, to show the results from several simulations not only one, in a formatted table. Compute the average over all simulations.arrow_forward
- Java homeworkarrow_forwardHow do I do this in Java language?arrow_forwardJAVA LANGUAGE Body Mass Index Version 2.0 by CodeChum Admin Recall that according to the National Heart, Lung, and Blood Institute of the National Institutes of Health, body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. It is used to monitor one's health by determining whether one is underweight, overweight, has normal weight or is obese. It is computed based as follows (when using standard weight in pounds and height in inches): BMI = 703 x (weight/(height2)) Furthermore, people with BMI scores that are less than 18.5 are said to be underweight. Those with scores between 18.5–24.9 (inclusive) are of normal weight. Those with scores between 25–29.9 (inclusive) are said to be overweight. And those with scores 30 or higher are obese. Input The input is composed of two positive integers representing the weight in pounds and the height in inches. 140·65 Output A single line containing two values: the computed…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning