Lab 4
Lab 4
Bock Repair Parts Sales operates a used automotive sales lot. Management requires an
application that will compute automotive sales information for the sale of a used vehicle. You are
to develop an application to compute the total due from a customer purchasing a used vehicle –
the customer may have a trade-in vehicle. Sometimes the company sells used vehicles to other
used automotive lots and offers them a discount on the price of the vehicle. This is termed a
wholesale dealer discount.
Getting Started.
project Lab4-SectionTime-YourLastName-YourFirstName as you did for previous
projects. The form’s File Name property should be Lab4
Save the project as you have for previous projects.
Requirements. Develop a form that is similar to the one shown below. You may have minor
differences.
The application user will enter the lot number that identifies a vehicle, the year, and the vehicle
make and model as shown in the figure above.
Price and Trade-in:
o The price for a vehicle is negotiated and entered into the price TextBox control.
o If the purchaser has a trade-in vehicle, the value of the trade-in is negotiated and this
value is entered into the trade-in TextBox control.
o If the purchaser does not have a trade-in, then the value “0.00” should display in the
trade-in TextBox control.
Discounts: If the buyer is another car dealership, then the application user will check the
wholesale discount checkbox and this will give the purchasing wholesale dealer a 20%
discount on the vehicle price only.
Extras: Sometimes customers wish to have a used vehicle touched-up or have extras
added prior to taking possession of the vehicle. Extras are not included in the price and the
customer pays extra according to the table given below. For Exterior Extras, the None
RadioButton control should be checked as the default when the form starts up.
Subtotal: This is computed as the price less the amount of discount (if any) plus the cost
of extras (if any).
Sales Tax: Regular customers must pay a state sales tax on their purchase. The tax rate
is 5% and is computed on the subtotal. Wholesale dealers purchasing a vehicle do NOT
pay any sales tax.
Total due: This is computed as the subtotal plus the sales tax less the value of the trade-
in (if any).
Constants: You must declare constants to store the wholesale discount rate, sales tax
rate, and cost of exterior and accessory extras, as appropriate.
Design.
Use GroupBox, Label, TextBox, RadioButton, CheckBox, and Button controls as shown in
the figure.
Input TextBox controls include the lot number, year, vehicle make/model, price, and trade-
in.
Left and right-align data as shown in the figure.
The output TextBox controls are all set to read-only with the TabStop = False.
The tab order must be top to bottom, left to right within the GroupBox controls. Note, when
tabbing to a GroupBox that contains RadioButton or CheckBox controls the application user
must use the up/down arrow keys on the keyboard to select between these controls.
All Buttons are enabled on startup and remain enabled throughout use of the application.
Assign hot keys to all Button controls. Also assign hot keys set to Label controls that are
associated with input TextBox controls and CheckBox controls. You decide which letters on
the controls to use as hot keys.
Map the Compute Button control to the keyboard Enter key; map the Reset Button control
to the keyboard Esc key.
On startup, the trade-in TextBox control should display a value of 0.00 – this will enable the
application user to tab past this control whenever there is no trade-in vehicle.
Programming Events.
Add remarks to the program as required.
You must set OPTION STRICT ON.
Validating Data. You must write code to enforce the business rules listed below whenever
the Compute Button control is clicked.
o Rule #1 – the lot number TextBox cannot be blank.
o Rule #2 – the year TextBox cannot be blank.
o Rule #3 – the vehicle make/model TextBox cannot be blank.
o Rule #4 – the price TextBox must contain a numeric value that is greater than zero
(no vehicles are given away).
o Rule #5 – the trade-in TextBox must contain a numeric value that is greater than or
equal to zero (allowing a zero value allows for customers that have no trade-in).
Compute Button Coding. Data is entered into the input TextBox controls. This includes
entering the lot number, year, vehicle make/model, checking the wholesale dealer discount
CheckBox control if appropriate, entering the price, and entering a trade-in value if
appropriate. Next application users select among the exterior and accessory extras. Only
one exterior extra can be selected, but users can select zero, one, or more accessory
extras. When the Compute Button is clicked, your code must:
o Declare variables and constants as required.
o Use a Try-Catch block to catch any exceptions that may occur including those
associated with data entry as general exceptions.
o Use an If-ElseIf-Else-End If structure to enforce all business rules.
o Compute the wholesale discount using the discount rate when the wholesale
discount Checkbox is checked; otherwise, the discount is zero. The discount applies
to the price only – extras are charged at the full rate.
o Compute the cost of extras (hint: use a local accumulation variable to accumulate
both exterior and accessory extra charges).
o Compute the subtotal, sales tax, and total due.
o Use the Round method as appropriate for calculations.
o Use the Parse and Convert methods as appropriate within the program.
o Accumulate the grand total due (that is the total of all total due values) to a decimal
variable. Accumulate a count of the number of vehicles sold to an integer variable –
you can assume that when the Compute button is clicked, a vehicle has been sold.
Exit Button Coding. When the Button is clicked, do not automatically close the
form. Instead, write code to only close the form if the application user responds Yes to the
question shown in this figure. The code should default the selection to the No button.
Test the Lab. Use the assessment guidelines provided below to test your lab work. This is the
same set of assessment guidelines that will be used to grade your work.
Use the test data given here for initial program testing. You will need to use additional test
sets to thoroughly test the application.
In addition to the test data shown below, ensure that you test for invalid data by creating
your own test procedures for a missing vehicle ID, missing description, missing/non-
numeric price, price that is zero or less than zero, non-numeric trade-in, or trade-in that is
less than zero.
Test Set #1: Click Compute without entering any data – program displays “Lot number is missing”
message, nothing is computed or displayed.
Test Set #2: Enter any lot number, click compute without entering the rest of the data – the
program displays a “Year is missing” message, nothing is computed or displayed.
Test Set #3: Enter any lot number, a year, and click compute without entering the rest of the data
– the program displays a “Vehicle make/model is missing” message, nothing is computed or
displayed.
Test Set #4: Enter all of the data for the Used Automotive Information GroupBox and click
compute without entering the rest of the data – the program displays a “Price must be a number
greater than zero” message, nothing is computed or displayed. Repeat this test with a non-
numeric value such as “ABC” and again for a value of zero or a negative value.
Test Set #5: Enter all data values, but change the trade-in to “ABC” – the program displays
“Trade-in must be a number and cannot be less than zero” message, nothing is computed or
displayed. Repeat this test by entering a negative number for trade-in.
For the remaining test sets, enter any lot number, year, and vehicle make/model. The test data
and results are shown in this table.
What to Do When You’re Finished, How to Save and Submit the Lab.
Ok, you’ve finished the lab. Do NOT use the File menu, Save As option. Instead, follow these
steps.
First, CLOSE Visual Studio—you cannot copy the project to another location if it is open.
Locate the folder that contains the project. It should be located in either the My
Documents or C:\Temp folder where you first saved the project.
Copy the entire folder to a flash drive.
Bring the flash drive to the University to either a computer lab or to the computer
classroom. Copy the entire folder to drive Y: to the submission folder for your class. You
can copy the folder to drive Y: at the beginning of the class period when the project is due.
Assessment of Project. Your work will be evaluated in terms of major and minor errors. The
point deductions are explained below. An assessment (test) plan is provided that lists the different
types of errors.
Major errors – multiple points are deducted for major errors.
Minor errors – one point is deducted for EACH minor error.
Startup.
Project will not compile and run – if some coding effort was made, stop grading now and
assigned 15 out of 40 points – a program that will not run does not get a passing grade. If
a poor effort was made, stop grading now and assign 5 out of 40 points simply to indicate
that the project was submitted. If the project is submitted with the form constructed, but
there is no programming code you will receive a grade of zero points – a project with no
programming code is not worth any points.
Form starts up centered on the screen. Form is an appropriate size.
Trade-in TextBox displays value 0.00 on startup.
Focus is on the lot number TextBox control – the Tab Order for the form is correct
All Button controls are enabled.
The None option of the Exterior Extras GroupBox is checked on startup.
None of the CheckBox controls are checked (they should all be unchecked).
Compute Button Click Event.
Output TextBox controls are formatted appropriately (missing dollar sign or has dollar sign
where it is not desirable).
Discount is correct (-2 if shows a discount other than 0.00 when the CheckBox is not
checked; -2 if fails to have correct discount when CheckBox is checked).
Cost of Extras is correct ( -1 for each data set the value is wrong; maximum -3).
Subtotal is correct (-2 if wrong – deduct points only if the error is NOT due to an error in
one of the above).
Sales Tax due is correct (-2 if whole sale customer with CheckBox checked is charged tax;
-2 if customer is not charged tax when they should be charged tax and the amount is
wrong).
Total due is correct (-2 if wrong formula).
Accumulates grand total due (-2 if not coded).
Accumulates count of number of vehicles sold (-2 if not coded).
Other Errors.
During program execution, your computer program should compile and execute without
generating any error messages – if the program will not compile or generates error
messages during execution, you will lose up to 35 points depending on the severity of the
error.