Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement Design and implement a Graphical User Interface (GUI) application that computes auto loan payments. The developed GUI allows a user to compute monthly

Problem Statement

Design and implement a Graphical User Interface (GUI) application that computes auto loan payments. The developed GUI allows a user to compute monthly loan payments interactively according to vehicle base price, down payment, option costs, and sales tax.

Project Requirements

Graphical User Interface: Reference the figure below and construct a GUI very similar to Figure 1.

Figure 1. Initial GUI display before any user interaction.

Implementation Requirements

Initial GUI Construction

  1. Your application should utilize various layout containers to achieve a similar appearance.

  2. The application is divided into five different sections indicated by blue circles:

Figure 2. The five main sections of the GUI

a. Payment Information section displays the calculated loan amount, monthly payment, and total payment.

i. It contains a Label for the section title, 3 Labels showing the payment titles, and 3 Labels displaying the dollar amounts.

b. Loan Term section provides a choice of month amounts to pay off the loan. i. It contains a Label for the section title and 4 RadioButtons for each loan

month amount. c. Financing Information section allows entering base price of the vehicle and a

down payment. It also displays the sales tax based on loan term. i. It contains a Label for the section title, 3 Labels showing the price and tax,

and 3 Labels displaying the dollar amounts. d. Price with Options section provides several vehicle features for additional cost.

i. It contains a Label for the section title and 5 CheckBoxs for optional features.

e. The bottom button section allows the user to user proceed with auto loan calculation, reset the UI fields, or exit the application.

i. It contains 3 Buttons, one for each operation.

3. Set the default values of GUI components and other data: Default sale tax: 7% Default loan term: 24 months Default options selected: Antilock brake

Default annual interest rate (not displayed on the GUI): 7%

4. (+5 Pts Extra Credit) You may develop the application with up to 5 classes:

a. One class each (4 total) for the PaymentSection, LoanTermSection, FinancingSection, and OptionsSection.

i. Event handlers should be written in the corresponding section.

  1. One class for the overall AutoLoanCalculator GUI to hold the four top sections,

    the button section, and the button event handlers

  2. If you choose to use one class, you will receive no extra credit. Regardless, make

    sure the code is easily readable by properly organizing with good naming

    conventions, spacing, and comments!

  3. There is an example on Brightspace that shows a way to make a section that is

    just a customized variant of a layout container. It uses principles from Chapter 10 Inheritance that you will understand better in the future! For now, check out the example and try to do something similar for this project.

Event Handling

  1. When a RadioButton is clicked:

    • If 24 Months is selected, set the annual interest rate to 7.0%.

    • If 36 Months is selected, set the annual interest rate to 6.0%.

    • If 48 Months is selected, set the annual interest rate to 5.5%.

    • If 60 Months is selected, set the annual interest rate to 5.0%.

  2. When the Reset Button is clicked:

    • Set values of Labels in Payment Information section to 0.0.

    • Set the Loan Term to 24 months.

    • Set values of Base Price and Down Payment TextFields to 0.0.

    • Set the value of Sales Tax TextField to 7.0.

    • Select the Antilock Brake CheckBox and deselect all others.

  3. When the Exit Button is click, exit the application.

  4. When the Calculate Button is clicked:

    • Read the values from Base Price, Down Payment, and Sales Tax TextFields.

    • Compute the sales tax based on the following formula:

      tax = (basePrice downPayment + optionCosts) * taxRate

      Make sure you convert the tax rate to the proper decimal value.

    • Compute the total optional features cost. (Using a separate method might be a good idea.)

  • Compute the Total Loan Amount based on the following formula: loanAmount = basePrice downPayment +

  •  optionCosts + tax 
  • Compute the Monthly Payment based on the following formulae: monthlyInterest = annualInterestRate / 12;

    Make sure you convert the interest rate to the proper decimal value.

    monthlyPayment = totalLoanAmount * (monthlyInterest * Math.pow(1 + monthlyInterest, months)) / (Math.pow(1 + monthlyInterest, months) - 1);

  • Compute the Total Payment based on the following formula: Total_Payment = Monthly_Payment *

    Loan_Term_In_Month + Down_payment

  • Display the computed Total Loan Amount, Monthly Payment, and Total Payment on the corresponding Labels of the Payment Information section.

    o All dollar amounts must be rounded to two decimal places. Remember using DecimalFormat or String.format are easy ways to do

    this.

  • Reference examples below to verify your implementation for the Calculate Button event handling.

Testing Sample Inputs/Outputs

When the user enters Base Price of 42,000, Down Payment of 7,000, Sales Tax of 7%, 48 months Loan Term, and option selections of Auto Transmission, AntiLock Brake, Sun Roof, and Audio Package, the GUI will show the following results:

When the user enters Base Price of 26,000, Down Payment of 2,000, Sales Tax of 4.8%, 36 months Loan Term, and option selection of Auto Transmission and Audio Package, the GUI will show the following results:

After the user clicks on the Reset button:

Notes

  • Assume the user always enters valid input values.

  • The computed prices can be slightly different depending on the way of handling floating

    point values. Please ignore any value differences smaller than a dollar.

  • You may not achieve the desired alignment of the dollar amounts in the Payment

    Information section. You do not have to, but if you are interested then you may reference the Hints section

    Hints / Useful Methods

If you are using individual classes for the top sections, make the class extend the type of layout container you want it to be:

o Ex. public class PaymentSection extends GridPane{ ...

} o Then call inherited GridPane methods using the class itself: o Ex. add(paymentLbl, 0, 0);

  • To change the font to bold or set a black border around a layout container, you can use the setStyle method:

    o control.setStyle("-fx-font-weight:bold"); o container.setStyle("-fx-border-color:black");

  • The setAlignment method can help position controls:

o buttonBox.setAlignment(Pos.CENTER); To adjust the spacing of specific columns in a GridPane, you can use the

getColumnConstraints method and add your own constraints: o ColumnConstraints c2 = new ColumnConstraints();

c2.setPrefWidth(80); c2.setHalignment(HPos.RIGHT);

ColumnConstraints c1 = new ColumnConstraints();

gridPane.getColumnConstraints().addAll(c1, c2);

Submission

Submit your zipped project to Brightspace.

Evaluation

Correctness (80 points). These points will be allocated as follows:

10 points: error-free compilation of the Java source files. 28 points: correct construction of the GUI. 42 points: correct performance of the application and correct results.

Design (10 points). These points will be allocated based on data fields, methods, class(es), and algorithms used in application.

Documentation and Style (10 points): You are expected to include comments anywhere the code is reasonably complex, dedicated to a general task, and/or you feel the reader of your code may need extra information that is not obvious from the code itself. This may include class descriptions, method descriptions, and comments for each major code section of a class. Additionally, you are expected to name your classes, variables, and methods in a way that optimizes readability in your application (This is called self-documenting or self- commenting code).

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

Mastering Big Data Interview 751 Comprehensive Questions And Expert Answers

Authors: Mr Bhanu Pratap Mahato

1st Edition

B0CLNT3NVD, 979-8865047216

More Books

Students also viewed these Databases questions

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago

Question

Factors Affecting Conflict

Answered: 1 week ago

Question

Describe the factors that lead to productive conflict

Answered: 1 week ago

Question

Understanding Conflict Conflict Triggers

Answered: 1 week ago