Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

my code is not adding up for this practice Problem Statement Design and implement a Graphical User Interface (GUI) application that computes auto loan payments.

my code is not adding up for this practice image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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. I Auto Loan Calculator Payment Information Loan Term Total Loan Amount: $ 0.0 24 Months Monthly Payment: $ 0.0 36 Months Total Payment: $ 0.0 48 Months 60 Months Financing Information Price with Options Base Price: $ 0.0 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 0.0 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit 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: CS161 Introduction to Computer Science II 1 Auto Loan Calculator Payment Information Loan Term Total Loan Amount: $ 0.0 O 24 Months Monthly Payment: $ 0.0 36 Months Total Payment: $ 0.0 48 Months 60 Months Financing Information Price with Options Base Price: $ 0.0 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 0.0 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 ra I Auto Loan Calculator Payment Information Loan Term Total Loan Amount: $ 0.0 24 Months Monthly Payment: $ 0.0 36 Months Total Payment: $ 0.0 48 Months 60 Months Financing Information Price with Options Base Price: $ 0.0 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 0.0 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit 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 CheckBox's for optional 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 CheckBox's 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% CS161 Introduction to Computer Science II 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 Options Section. i. Event handlers should be written in the corresponding section. 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. b. One class for the overall AutoLoanCalculator GUI to hold the four top sections, the button section, and the button event handlers c. 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! d. 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: 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 = (base Price - 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.) CS161 Introduction to Computer Science II Compute the Total Loan Amount" based on the following formula: loanAmount = basePrice - down Payment + 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. All dollar amounts must be rounded to two decimal places. Remember using DecimalFormat or String.format are easy ways to do this. o . Reference examples below to verify your implementation for the Calculate Button event handling CS161 Introduction to Computer Science II 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: Auto Loan Calculator Payment Information Loan Term Total Loan Amount: $ 43174.50 24 Months Monthly Payment: $ 1004.09 36 Months Total Payment: $ 55196.16 48 Months 60 Months Financing Information Price with Options Base Price: $ 42000 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 7000 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit CS161 Introduction to Computer Science II 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: Auto Loan Calculator x Payment Information Loan Term Total Loan Amount: $ 28662.80 24 Months Monthly Payment: $ 871.98 36 Months Total Payments 33391.20 48 Months 60 Months Financing Information Price with Options Base Price: $ 26000 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 2000 Sun Roof: $800 Sales Tax: % 4.8 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit After the user clicks on the Reset" button: Auto Loan Calculator O X Payment Information Loan Term Total Loan Amount: $ 0.0 24 Months 0.0 36 Months Monthly Payment: $ Total Payment: $ 0.0 48 Months 60 Months Financing Information Price with Options Base Price: $ 0.0 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 0.0 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit 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 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. I Auto Loan Calculator Payment Information Loan Term Total Loan Amount: $ 0.0 24 Months Monthly Payment: $ 0.0 36 Months Total Payment: $ 0.0 48 Months 60 Months Financing Information Price with Options Base Price: $ 0.0 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 0.0 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit 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: CS161 Introduction to Computer Science II 1 Auto Loan Calculator Payment Information Loan Term Total Loan Amount: $ 0.0 O 24 Months Monthly Payment: $ 0.0 36 Months Total Payment: $ 0.0 48 Months 60 Months Financing Information Price with Options Base Price: $ 0.0 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 0.0 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 ra I Auto Loan Calculator Payment Information Loan Term Total Loan Amount: $ 0.0 24 Months Monthly Payment: $ 0.0 36 Months Total Payment: $ 0.0 48 Months 60 Months Financing Information Price with Options Base Price: $ 0.0 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 0.0 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit 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 CheckBox's for optional 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 CheckBox's 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% CS161 Introduction to Computer Science II 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 Options Section. i. Event handlers should be written in the corresponding section. 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. b. One class for the overall AutoLoanCalculator GUI to hold the four top sections, the button section, and the button event handlers c. 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! d. 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: 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 = (base Price - 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.) CS161 Introduction to Computer Science II Compute the Total Loan Amount" based on the following formula: loanAmount = basePrice - down Payment + 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. All dollar amounts must be rounded to two decimal places. Remember using DecimalFormat or String.format are easy ways to do this. o . Reference examples below to verify your implementation for the Calculate Button event handling CS161 Introduction to Computer Science II 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: Auto Loan Calculator Payment Information Loan Term Total Loan Amount: $ 43174.50 24 Months Monthly Payment: $ 1004.09 36 Months Total Payment: $ 55196.16 48 Months 60 Months Financing Information Price with Options Base Price: $ 42000 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 7000 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit CS161 Introduction to Computer Science II 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: Auto Loan Calculator x Payment Information Loan Term Total Loan Amount: $ 28662.80 24 Months Monthly Payment: $ 871.98 36 Months Total Payments 33391.20 48 Months 60 Months Financing Information Price with Options Base Price: $ 26000 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 2000 Sun Roof: $800 Sales Tax: % 4.8 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit After the user clicks on the Reset" button: Auto Loan Calculator O X Payment Information Loan Term Total Loan Amount: $ 0.0 24 Months 0.0 36 Months Monthly Payment: $ Total Payment: $ 0.0 48 Months 60 Months Financing Information Price with Options Base Price: $ 0.0 Auto Transmission: $1800 AntiLock Brake: $1200 Down Payment: $ 0.0 Sun Roof: $800 Sales Tax: % 7.0 Navigation System: $1350 Audio Package: $1550 Calculate Reset Exit 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

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

Which state takes the most time to ship to in February 2020?

Answered: 1 week ago