Question: 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 (set to 10,000)
  • Interest Rate (set to 0.05)
  • Years (the life of the loan) (set to 2)

Additionally, your class should store the following class constants (following standard coding convention of capitalizing the letters):

  • The number of periods per year (set to 12)
  • An invalid dollar amount (set to -1.0)
  • Required monthly payment (the equation in Math.round(initialBalance* ((interestRate/paymentPerYear)+((interestRate/paymentPerYear)/Math.pow(1+(interestRate/paymentPerYear), paymentPerYear*years - 1) - 100.00)))/100.00)
  • 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)
    The second argument is the type and can have the following values:
    • "interest"
    • "principal"
    • "balance"
    The method should return the dollar amount (so, rounded to 2 decimal places) for the type for the appropriate month. If either the type or the month is not one of the terms above, then return the invalid dollar amount (a class constant)
  • 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!