***must be in java please***

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

***must be in java please***

Post by answerhappygod »

***must be in java please***
Must Be In Java Please 1
Must Be In Java Please 1 (238.05 KiB) Viewed 39 times
Must Be In Java Please 2
Must Be In Java Please 2 (254.59 KiB) Viewed 39 times
Must Be In Java Please 3
Must Be In Java Please 3 (136.04 KiB) Viewed 39 times
Build a mortgage calculator using the following formula: r.(1+r)" M = P (1 + r)" – 1 Where: o M is the mortgage that needs to be calculated by your code. The type of it is double. You should import java.text.NumberFormat and use this package for formatting the mortgage to be shown in currency format. o P is the principal (the amount of the loan you want to get). The type of it is int. The range of the values that you can enter is $1K – $1M, inclusive. If the user enters a number out of range, an error message must be printed on the terminal which says "Enter a value between 1000 and 1,000,000. You ask for the principal again. If you keep entering invalid numbers, it will keep printing the error message, until the vale entered is valid. O r is the monthly interest rate. The type of it is float. You are going to ask the user to enter the annual interest rate. The range of the values that you can enter for the annual interest rate is 1 to 30, inclusive. If the user enters a number out of range, an error message must be printed on the terminal which says, "Enter a value between 1 and 30". You ask for the annual interest rate again. If you keep entering invalid numbers, it will keep printing the error message, until the vale entered is valid. This number must be divided by 100 (define as constant) and then divided by 12 to get the monthly interest rate (r).
a an On is the total number of payments. The type of it is short. You are going to ask the user to enter the number of years. The range of the values that you can enter for the number of years is 1 to 30, inclusive. If the user enters number out of range, error message must be printed on the terminal which says, "Enter a value between 1 and 30". You ask for the number of years again. If you keep entering invalid numbers, it will keep printing the error message, until the vale entered is valid. This number must be multiplied by 12 (define as constant) to get the total number of payments (n). O Your code must start with a comment which includes your name. Your code must have sufficient comments. O O Please do not use the names that we have in the formula (I mean names like r,M,P). Since it's a math formula we used these. In your code, you should use comprehensive names (for example numberofPayments for n)
O Besides main method, your code should have the following methods: public static double calculateMortgage (int principal, float annualInterest, byte years) Note have that This the method will the mortgage calculation formula. constants like 12 and 100 that we discussed before, must be defined here as constants. public static double readNumber (String prompt, double min, double max) As you noticed you will have several while(true) loops in your code that in each of them you are going to compare the scanned value with the valid range. As discussed in class, you can use refactoring to omit repetition. We use the readNumber() method for refactoring. O To test your program, if: principal=1,000,000 annual interest rate = 3.92 number of years = 30 Mortgage (M) must be shown as $4,728.13 in terminal.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply