Question: Can someone help with writing the code so I can create the app itself? Scenario: Your team has been hired by Flybai-Knight Auto (FKAuto) to
Can someone help with writing the code so I can create the app itself?
Scenario:
Your team has been hired by Flybai-Knight Auto (FKAuto) to help them automate their antiquated operation for used cars sales. For your first assignment, you are to develop a point-of-sale app that accepts a customer's name, car price, and state of residence. The app will then calculate and display a discount (based on price), the sales tax (according to state), and the total net sales amount.
Refer to the screenshots below for examples of how the UI should look and behave. Note that, any time the end-user presses the Enter key, that enters the data and causes the processing of those data to take place. Similarly, when the end-user presses the Esc key, the form data will be cleared and the form reinitialized. In addition, note the tab order, which starts with the textbox for the customer name, then goes to the textbox for the vehicle price, then to the state selection dropdown list, then to the main processing button, and finally to the button that clears the form.
Specifications:
The code for this app is to be comprised of three event-handler methods calcSaleButton_Click(), clearButton_Click(), and SalesForm_Load() and five independent methods: DetermineDiscount(), DetermineTax(), CalculatePrices(), and HandleOutput(), and ClearForm(). The relationships among these programming modules are indicated in the structure chart below, and the pseudocode below that summarizes the logic involved in each of the methods for this app.
The discount brackets and associated rates, as well as the state abbreviations and their corresponding tax rates, are to be assigned to the parallel arrays BRACKET and DISCOUNT_RATE, and STATE and TAX_RATE, respectively. The state abbreviations to be included in the dropdown list are AR, LA, MO, MS, OK, TN, and TX, and the sales tax rates for those states are 7%, 6%, 8%, 5.5%, 6.5%, 8.5%, 5%, respectively. The following are the values to be used in determining the proper discount rate.
None if sale < 500 10% if sale < 2000 20% if sale < 5000 30% if sale 5000
When the UI loads, the state selection dropdown list is to be populated from the STATE array, with potentially many state abbreviations in alphabetic order. (Use a foreach() loop for this purpose. Both when the UI loads and when it is cleared, the processing should also ensure that the Tennessee abbreviation (index 5, as specified for DEFAULT_STATE) is displayed by default.
Since potentially many discount rates, as well as states, are to be considered, both the discount rates and sales tax percentages are to be determined by means of if()/else constructs within foreach loops.
If the end-user enters bad data for the vehicle price, that error will need to be trapped. Therefore, you are to use the TryParse() method for assigning the vehicle price entered by the end-user inputs to the numeric variable that will be used in the calculations. The return value from that TryParse() method should be assigned to a Boolean variable, which is to be used to determine whether or not the price entered is valid. If the parsing fails, the user should be notified by means of a MessageBox (with an appropriate message and title), after which she/he will have the opportunity to correct the mistake. When the MessageBox is closed, the sale amount is to be selected, ready for the user to make the appropriate correction.
TOE chart:
Task Object Event Serve as container for sales processing I/O objects SalesForm Load Get and display the customer's name and vehicle price nameBox, priceBox None Get and display the customer's state of residence stateListBox None 1. Calculate the discount, tax, and net sales amount 2. Cause results to be displayed back to the form labels calcSaleButton Click Display the discount discountLabel None Display the sales tax taxLabel None Display the net sales amount netPriceLabel None Display a message summarizing the sale info resultSummaryLabel None Reset the form clearButton Click
Global variables and constants:
Integer constant: DEFAULT_STATE String constants: ERR_MESSAGE, ERR_TITLE String array: STATE Decimal arrays: TAX_RATE, BRACKET, DISCOUNT_RATE String variable: strName
Pseudocode outline for each of the methods:
SalesForm_Load
Populate the dropdown list: loop through the STATE array, adding items to stateListBox Initialize the form by calling ClearForm()
calcSaleButton_Click
Declare local variables:
Decimal: decSale, decDiscount, decTax, decTotal Boolean: blnPriceOK String:strState
Get data from form and convert data types as appropriate for:
Customer name Sale amount Customer state of residence
Validate vehicle price and process accordingly
If sale amount is valid, then do the following:
Determine the discountAmount (DetermineDiscount()) Determine the sales tax (DetermineTax()) Calculate sale amount net of discount and sales tax Create, format, and display text for output, e.g., currency to the penny (HandleOutput())
Otherwise: Display messagebox containing error message, reset focus, and select bad entry
clearButton_Click: Initialize the form (ClearForm())
DetermineDiscount
Input: sale amount Declare local variables
Decimal: discountAmount Integer: i (counter / array index)
Determine discountRate based on sale amount (use an if()/else construct within a foreach() loop)
Loop through BRACKET If sale amount < bracket
Assign corresponding element from the rate array and break out of loop Otherwise go to the next bracket
Calculate discountAmount (discountRate * saleAmount) Output: discount amount
DetermineTaxRate
Input: state abbreviation Declare local variables
Decimal: taxRate, taxRate Integer: i (counter / array index)
Determine sales tax rate based upon state (use an if()/else construct within a foreach() loop)
Loop through STATE If selected state = STATE element
Assign corresponding element from TAX_RATE array and break out of loop Otherwise go to the next STATE element
Output: tax rate
HandleOutput
Inputs: sale amount, total net price, discount amount, sales tax Declare local variables (all string): strSale, strTotal, strDiscount, strTax, strOutputMsg Create and format text for output
Convert numeric values to strings and assign to the individual labels:
Sale amount Discount amount Sales tax Net price
Generate block of text for primary output message Display the results to their respective form controls
Discount amount Sales tax Net price Primary output message
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
