Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Java code For this project, you get to design and write a class named Main that stores loan terms and has methods that use those
Java code
For this project, you get to design and write a class named Main that stores loan terms and has methods that use those terms. Your Main class should store the following loan terms:
- Initial Balance
- Interest Rate (the Annual Percentage Rate, stored as a rate not a percentage, for example 5% is 0.05)
- Years (the life of the loan)
Additionally, your class should store the following class constants (following standard coding convention of capitalizing the letters):
- The number of periods per year
- An invalid dollar amount (set to -1.0)
Additionally, store the following calculated loan values:
- Required monthly payment (see M above)
- Total Interest amount
- Total Payment amount
- First month's interest
- First month's principal
- First month's balance
- Last month's interest
- Last month's principal
- Last month's balance
Provide the following methods in your class:
- Constructor that take the initial balance (as a double), the interest rate (as a double) and the number of years (as a double)
- getMonthlyPayment() returns the required monthly payment (rounded to 2 decimal places) as a double
- getAmount() takes two Strings as arguments. The first is the month and can have the following values:
- "first" (meaning the first month)
- "last" (meaning the last month)
- "interest"
- "principal"
- "balance"
- getTotalInterest() returns the total amount of interest paid (rounded to 2 decimal places) as a double
- getTotalPayments() returns the total amount of payments paid (rounded to 2 decimal places) as a double
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started