VB Auto Center Chapter 4 Visual Basic Create a project that determines the total
ID: 3755330 • Letter: V
Question
VB Auto Center Chapter 4 Visual Basic
Create a project that determines the total amount due for the purchase of a vehicle. Include text boxes for the base price and the trade-in allowance. Check boxes will indicate if the buyer wants additional accessories: stereo system, leather interior, and/or computer navigation. A group box for the exterior finish will contain radio buttons for Standard, Pearlized, or Customized detailing.
Have the trade-in amount default to zero; that is, if the user does not enter a trade-in amount, use zero in your calculation. Validate the values from the text boxes, displaying a message box if necessary.
To calculate, add the price of selected accessories and exterior finish to the base price and display the result in a control called Subtotal. Calculate the sales tax on the subtotal and display the result in a Total control. Then subtract any trade-in amount from the total and display the result in an Amount Due control.
Include buttons for Calculate, Clear, and Exit. The Calculatebutton must display the total amount due after trade-in.
Hint: Recall that you can make an ampersand appear in the Text property of a control by including two
ampersands.
Explanation / Answer
* Place all controls including text boxes, labels, check boxes, radio buttons, command buttons, and group boxes on the form as shown. Set the Text values for all controls as indicated. Name the controls appropriately
* Use two text boxes to allow the system user to enter the Car Sales Price and the Trade-in Allowance.
* Use four labels to display the values that are computed for the Accessories & Finish, Sales Tax, Subtotal, and Amount Due values.
* Accessories and Car Exterior Finish options are priced as shown in this table. These values should be given appropriate names and stored as module-level constant values in your program.
Accessory
Price
Finish
Price
Stereo System
$425.76
Standard
No additional charge
Leather Interior
$987.41
Pearlized
$345.72
Computer Navigation
$1,741.23
Customized Detailing
$599.99
* At Design Mode:
o Disable the Clear button.
o Set the TabStop property for the buttons to False.
o Set the TabOrder to tab from the Car Sales Price to the Trade-In Allowance to the Accessories group box control (each check box will tab in turn in this control and are selected by pressing the space bar), to the Finish group box control (the up and down arrow keys move the selection).
o The Standard finish should be selected by default.
* On Startup:
o The checkboxes are all unchecked.
o All labels and text boxes are cleared (empty).
o Focus is initially set to the Car's Sales Price.
* Controlling Correct Data Entry:
o Do not accept a negative or non-numeric value for the Car Sales Price or Trade-In Allowance - Use a Message Box to give an appropriate error message when the Calculate button is clicked.
o The Message Box should clear after clicking an OK button one time to allow the system user to correct the error – your program must NOT compute or display any values if the Car Sales Price or Trade-In Allowance is invalid.
* Calculate button:
o Compute all values and display them in the appropriate labels as shown on the form above.
o Format ALL output labels and text boxes as right-justified and currency-formatted ($)
o Disable the Calculate button; enable the Clear button.
* Clear button:
o The check boxes should be unchecked.
o The Exterior Finish radio buttons should be reset such that the Standard option button is selected.
o The text boxes and labels that display currency values should be cleared.
o Set the focus to the Car Sales Price text box.
o Enable the Calculate button; disable the Clear button
* Exit button: Close the form.
Computing the Label Values:
* System users can select any combination of accessories (none, one, two, or all three). The system should start up with none of the Accessory checkboxes checked. System users can only select one finish. Compute the combined cost of all accessories and finish and display the value to the label.
* The Sales Tax is computed on both the Car Sales Price and the cost of Accessories and Finish. Store the Sales Tax Rate as a module-level constant (0.08D)
* The Subtotal is computed by adding the Car's Sales Price, cost of Accessories and Finish, and Sales Tax amount. Store this value to a variable. Display the Subtotal value formatted as currency to the label as shown in the form.
* The Amount Due is computed by subtracting the Trade-in Allowance from the Subtotal. Store the Amount Due to a variable and display the Amount Due value formatted as currency to the label as shown in the form.
* Refer to the grading form for this assignment for additional requirements.
HINTS ON THE LOGIC REQUIRED TO COMPLETE THIS ASSIGNMENT
You have to code one primary click event in this assignment - the btnCalculate_Click event. Given below is a diagram that illustrates the primary components of the logic required for this event. You will have to add additional actions that are necessary such as the details of the calculations and the enabling/disabling of buttons.
protected void rptShoppingCart_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
// To reset the counter incase of header
if (e.Item.ItemType == ListItemType.Header)
{
decPriceSum = 0;
}
// to add the product price to the sum variable (decPriceSum)
else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
decPriceSum +=
(decimal)((DataRowView)e.Item.DataItem)["prod_price"];
}
// to view the total incase of footer
else if (e.Item.ItemType == ListItemType.Footer)
{
Label lblSum = e.Item.FindControl("lblItemPrice") as Label;
lblSum.Text = "Total Price: $ " + decPriceSum;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.