Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description You have gotten your first co-op placement with the Student Financial Aid office. The manager would like you to code a prototype GUI student

Description

You have gotten your first co-op placement with the Student Financial Aid office. The manager would like you to code a prototype GUI student loan calculator app to let them see how modifying their repayment schedules would affect the loan cost in terms of the amount of interest that the student would pay.

NOTE: the current Student Assistance Program is being modified by the current state government, so actual repayment rules are in a state of flux. This app will follow fictional repayment rules created for this project only.

NOTE2: It is recommended to use Java Swing for this project, but you are also allowed to use JavaFX.

Classes Needed

1) Write a Student class based on the UML diagram shown below

image text in transcribed

The data member studentID is a String consisting of seven numeric characters. The leading character can be a zero, as in 0087901.

The data members cslLoanAmount and oslLoanAmount will hold the Canada Student Loan and Ontario Student Loan portions of the overall loan amount awarded to the student. The toString() method will return a String that contains the data shown just below:

Student Name: Pulling, William John

Student Number: 1111111

CSL Amount is $4500.0

OSL Amount is $3200.0

Next, write a StudentLoanApp class that extends JFrame. This class will have as a data member an ArrayList, to which Student objects can be added or removed as required. Your name and student number must be displayed in the title bar of the JFrame. Also, a label stating This is [your name]s Student Loan Calculator must appear as the top component inside the frame. This class will als

o be responsible for building the GUI. It will have one or more named inner classes that will be responsible for handling events from the GUI depending on what GUI components you decide to use.

Next, write an interface called Your_Intitials_LoanPayable.java that will hold a constant value called ANNUAL_RATE_TO_MONTHLY_RATE. Assign this constant the decimal equivalent value of 1/1200. You can then use this to convert whatever annual prime interest rate the user enters to the equivalents monthly rate decimal equivalent.

Your interface will also have an abstract method called calculateLoanPayment( ). This method will return a double value that represents the loan payment amount, and it will accept three arguments: a double representing the OSL or CSL principal amount, a double representing the annual prime interest rate, and an int value that represents the amortization period in months.

Design of the GUI: It is up to you, but here are some general guidelines.

Input Form : You need to create a form for the user to enter student data and the amounts of their loans. Include some data validation for the student number so that only numeric characters are entered here. This data will then be used to create a Student object, which will be entered into the arrayList when the user presses a Submit button. The form should also have a button to clear the fields for another student entry. Look for ways to minimize what the user has to type in.

Repayment Calculation Form: You need to create a form that will display all of the students data by retrieving the Student object from the arrayList and using its getter methods to put data onto the form. The form should have a control so that you can press a button to get to the next student in the list or go back to the previous student. Each time you go to a new student the data in the form should refresh.

The form should open and show the data for the first student in the arrayList, including the

- amount in dollars of his/her Canada Student Loan (CSL)

- amount in dollars of his/her Ontario Student Loan (OSL)

To minimize the possibility of a typing error, you need to provide a way for the user to select the current prime interest rate as an annual percentage i.e 4.25% per year, rather than have them type it into a JTextField. How you do this is up to you. Possibilities include providing a list of values from a drop down list, or using some other component such as a JSlider or a JSpinner NOTE: interest rates will measured in quarter percent increments, so an interest rate of 4.25% or 4.50% is valid, but a rate of 4.35% or 4.40% would not be valid.

There needs to be a text field or some other type of control where the user can enter the amortization period in months, which is the number of months over which repayment will be made. If the repayment was to be spread over five years, then the amortization period in months will be (5 * 12) = 60 months.

The repayment form needs a JButton that the user can press so that the app will then calculate and display the monthly payments required to pay back both parts of the loan, the combined monthly total payments, the total amount that will be repaid with interest, the original amount borrowed, and the total amount of interest that is paid.

Formula for Calculating the Monthly Payments

The interest rate on a Canada Student Loan is prime rate plus 2.5% (in other words if the primeinterest rate is 4.25%, the interest rate on a CSL is (4.25 + 2.5) = 6.75%.

The interest on an Ontario Student Loan is prime rate plus 1.0% (in other words if the prime interest rate is 4.25%, the interest rate on an OSL is ( 4.25 + 1.0) = 5.25%.

The formula for calculating the monthly payment P on a loan of amount A with a monthly interest rate of i over an amortization period of N months is:

P = A * i * (1 + i)N / ( (1 + i)N 1)

IMPORTANT! The above formula uses a monthly interest rate expressed as a decimal equivalent rate. To obtain this, you need to multiply the annual interest rate by 1/1200.

Now, multiplying the annual rate by 1/1200 is mathematically equivalent to first dividing the entered annual prime interest rate by 12 to convert the annual interest rate to a monthly interest rate, then dividing this monthly interest rate by 100 to convert from it a percentage to its decimal equivalent, which is what we need to use in the actual formula shown above.

Your interface Your_Intitials_LoanPayable.java will hold a constant value called ANNUAL_RATE_TO_MONTHLY_RATE. Assign this constant the decimal equivalent value of 1/1200. You can then use this to convert whatever annual prime interest rate the user enters to the equivalents monthly rate decimal equivalent.

This interface will also have an abstract method called calculateLoanPayment( ). This method will return a double value that represents the loan payment amount, and it will accept three arguments: a double representing the OSL or CSL principal amount, a double representing the annual prime interest rate, and an int value that represents the amortization period in months.

Event Handling: please do all of your event handling in one or more named inner classes. This makes it easier for your teacher to assess your event handling code. One of your inner classes will have to implement your interface method to do the calculations of the monthly loan payment.

Here is a complete sample calculation that uses the sample data shown.

Part 1 Canada Student Loan (CSL):

A = $2500.00 The loan amount is $2500.

i = 0.005625 The prime interest rate is 4.25%. The CSL uses an interest rate of prime plus 2.5, which would be 6.75%. To convert this annual rate to a monthly interest rate expressed as a decimal we multiply 6.75 * 1/1200 to get a monthly rate of 0.005625.

N = 60 The amortization period is 60 months.

Step by step calculations

P = A * i * (1 + i)N /( (1 + i)N 1)

= 2500 * 0.005625 * (1 + 0.005625)60 / ( (1 + 0.005625)60 1)

= 2500 * 0.005625 * ( 1.40011493 ) / ( (0.40011493) )

= 49.20865

= $49.21 per month (rounded)

Part 2 Ontario Student Loan (OSL):

A = $1500.00 The loan amount is $1500.

i = 0.004375 The OSL uses an interest rate of prime plus 1.0, which is 5.25%. To convert this to a monthly interest rate expressed as a decimal this would be 5.25 * 1/1200 or 0.004375.

N = 60 The amortization period is 60 months.

P = A * i * (1 + i)N /( (1 + i)N 1)

= 1500 * 0.004375 *(1 + 0.004375)60 / ( (1 + 0.004375)60 1)

= 1500 * 0.004375 * (1.299432266) / ( 0.299432266)

= 28.47897576

= $28.48 per month (rounded)

Total monthly payment is the sum of the two individual loan payment amounts.

Therefore the monthly payments are $49.21 for the CSL and $28.48 for the OSL for a combined monthly payment of $77.69 on an amortization period of 60 months.

Methods

You must implement the abstract method calculateLoanPayment( ).that is declared in your interface. It will calculate a monthly payment according to the formula given above. This method should accept three arguments: the loan amount, the annual interest rate that is being charged for the particular loan type (remember, you pay prime + 1.0 on the Ontario student loan amount, and prime + 2.5 for the Canadian student loan amount) , and the amortization period (number of months). The method will return the monthly payment in dollars and cents rounded to the nearest cent to the line of code that called the method. Note that you will call this method twice during your calculations, once to calculate the monthly payment for the CSL and again to calculate the monthly payment for the Ontario Student Loan amount.

Exception Handling:

Create your own custom exception class called Your_Intitials_NegativeValueException.java and implement it in the appropriate method using try and catch blocks.

The idea here is that if the user enters a negative value in either of the two input fields, then this exception should be thrown and then caught in a try-catch structure. The catch block should have code that will pop up a JOptionPane warning message box that advises the user that they cannot enter a negative value in the input fields. The message should then say that it will convert the negative value to a positive one and continue with the calculations. When the user clicks on the OK button of the message box, the application will do exactly thatconvert the negative value to a positive one and continue with the calculations.

+Student(String: studentID, String: surname, String: middleName, String: firstName, String: aptNumber, String: streetNumber, String: streetName, String: city, String: state, String: zipCpde, double: cslLoanAmount, double: oslLoanAmount) Provide a full set of getters for each data member, Provide setters for every data member except studentlD. +toString(): String +Student(String: studentID, String: surname, String: middleName, String: firstName, String: aptNumber, String: streetNumber, String: streetName, String: city, String: state, String: zipCpde, double: cslLoanAmount, double: oslLoanAmount) Provide a full set of getters for each data member, Provide setters for every data member except studentlD. +toString(): String

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Financial Machine Learning

Authors: Marcos Lopez De Prado

1st Edition

1119482089, 978-1119482086

More Books

Students also viewed these Finance questions

Question

180 degree is radian O a. Pi O b. b. Pi/2 O c. Pi/3 O d. 2Pi

Answered: 1 week ago