iLAB OVERVIEW
Scenario/Summary
In this lab, you’ll implement an application that performs a simple sales tax calculation. The new feature of this application, compared to what you have done in previous iLabs, is that the values entered by the user will be checked for validity. If the amounts entered are invalid, the application will display appropriate error messages to the user. If the input data are valid, the application will calculate the sales tax due and the total, including tax.
Sales Tax Application Business Requirements
The user enters an order amount and a sales tax percent. The order amount must be numeric and greater than 0. The sales tax percent must be numeric, greater than or equal to 0, and less than or equal to 0.14. If the input data are invalid, appropriate error messages will be displayed to the user. If the input data are valid, the application will calculate the sales tax by multiplying the order amount by the sales tax percent, and will calculate the order total, including tax, by adding the order amount and the sales tax. The sales tax and the order total, including tax, will be displayed to the user.
TOE Chart for Sales Tax Application
|
Task |
Object |
Event |
|
Get the following inputs from the user: |
||
|
Order amount |
txtOrderAmount |
|
|
Sales tax percent |
txtTaxPercent |
|
|
Perform the following processing: |
btnCalcTotal |
Click |
|
Validate inputs |
||
|
Calculate Tax = Order amount * Sales tax percent |
||
|
Calculate Order total = Order amount + Tax |
||
|
Display the following outputs: |
||
|
Error messages (if input invalid) |
lstMessages |
|
|
Tax (if input valid) |
lstMessages |
|
|
Order total (if input valid) |
lstMessages |
Pseudocode for Sales Tax Application
Start button-click event handler
Declare numeric variables for
Order amount
Sales tax percent
Tax
Order total
Declare string variables for
Order amount message
Sales tax percent message
Declare Boolean variable for
Inputs valid (initialize to True)
Clear messages
Call ValidateOrderAmount function with Order amount, returning Order amount message
If Order amount message is not empty (i.e. there was an error)
Display Order amount message
Set Inputs valid to False
End If
Call ValidateSalesTaxPercent function with Sales tax percent, returning Sales tax percent message
If Sales tax percent message is not empty (i.e. there was an error)
Display Sales tax percent message
Set Inputs valid to False
End If
If Inputs valid is True
Get Order amount
Get Sales tax percent
Calculate Tax = Order amount * Sales tax percent
Calculate Order total = Order amount + Tax
Display Tax
Display Order amount
End If
Stop button-click event handler
Start ValidateOrderAmount function (Order amount)
If Order amount is not numeric
Set Order amount message to “Please enter a numeric order amount.”
Else If Order amount is less than or equal to zero
Set Order amount message to “Please enter an order amount greater than zero.”
Else
Set Order amount message to the empty string (no error)
End If
Return Order amount message
Stop ValidateOrderAmount
Start ValidateSalesTaxPercent (Sales tax percent)
If Sales tax percent is not numeric
Set Sales tax percent message to “Please enter a numeric sales tax percent.”
Else If Sales tax percent is less than zero or greater than 0.14
Set Sales tax percent message to “Please enter a sales tax percent between 0.00 and 0.14.”
Else
Set Sales tax percent message to the empty string(no error)
End If
Return Sales tax percent message
Stop ValidateSalesTaxPercent
Deliverables
Submit a Word document named Lab5YourFirstLastName.docx (where YourFirstLastName = your first and last name; e.g., Lab5JohnSmith.docx) containing the following:
- Screenshot of form showing the application running, with non-numeric entries for Order amount and Sales tax percent, and appropriate error messages displayed.
- Screenshot of form showing the application running, with out-of-range entries for Order amount and Sales tax percent, and appropriate error messages displayed.
- Screenshot of form showing the application running, with valid entries for Order amount and Sales tax percent, and correct Tax and Order total results displayed.
- Copy of code for button-click event, ValidateOrderAmount function, and ValidateSalesTaxPercent function.
|
Category |
Points |
% |
Description |
|
Create and rename form |
5 |
10% |
Windows form was created and renamed SalesTax.vb. Form text property was set toLab 5 Your Name (where Your Name = your full name). |
|
Add controls to form |
5 |
10% |
The following controls were added to the form: Identifying labels and text boxes for entry of order amount and sales tax percent; button to calculate total including tax; and list box for display of error messages and results. |
|
Set properties for controls |
5 |
10% |
Name and text properties of all controls were set appropriately, with no typos or spelling errors. |
|
Code button-click event |
5 |
10% |
Button-click event code was entered that corresponds to the given pseudocode, with no syntax errors. |
|
Code ValidateOrderAmount function |
5 |
10% |
Function code was entered that corresponds to the given pseudocode, with no syntax errors. |
|
Code ValidateSalesTaxPercent function |
5 |
10% |
Function code was entered that corresponds to the given pseudocode, with no syntax errors. |
|
Test-run application successfully |
20 |
40% |
Application is shown running successfully with screen shots for each of the three test cases: (1) non-numeric entries for order amount and sales tax percent, with appropriate error messages; (2) out-of-range entries for order amount and sales tax percent, with appropriate error messages; and (3) valid entries for order amount and sales tax percent, with correct tax and order total results. |
|
Total |
50 |
100% |
Required Software
Visual Studio 2012
Access the software athttps://lab.devry.edu.
Steps: all
iLAB STEPS
Step 1: Launch Visual Studio and Create Project
Back to Top
(a) Log into the Citrix iLab site as you did in the previous labs. Click the Microsoft Visual Studio 2012 icon to launch Visual Studio.
(b) Pull down the File menu and select New Project . . .
(c) In the New Project dialog, ensure that under Templates in the left column, Visual Basic is selected, and that in the center column, Windows Form Application is selected. In the Name field at the bottom of the dialog, enter SalesTax. Click OK.
Step 2: Rename Form and Add Controls
Back to Top
(a) In the Solution Explorer pane on the right side of the screen, right-click on Form1.vb, select Rename, and change the name to SalesTax.vb. Press Enter after entering the new form name.
(b) Change the Text property of the form to Lab 5 Your Name (where Your Name = your full name), as you have done in previous labs.
(c) Drag the following controls from the ToolBox onto the form, arrange them in a logical fashion, and set their properties as indicated in the table below.
|
Control |
Name Property |
Text Property |
|
Label |
Label1 |
Order amount: |
|
TextBox |
txtOrderAmount |
|
|
Label |
Label2 |
Sales tax percent: |
|
TextBox |
txtSalesTaxPercent |
|
|
Button |
btnCalcTotal |
Calculate Total Including Tax |
|
ListBox |
lstMessages |
(d) Ensure that all controls are positioned and sized so that the form has a neat, professional appearance and none of the text is cut off. Your completed form should look similar to the following.
(e) Pull down the File menu and select Save All to save your work. If a Save Project dialog appears, ensure that the project is saved to the My DocumentsVisual Studio 2012Projects folder under your DSI number. Click Save.
Step 4: Test, Debug, and Submit
Back to Top
(a) Run the application by doing one of the following: click the Start button; pull down the Debug menu, and select Start Debugging; or press the F5 key.
(b) Your form should appear. Test your application by using the following test cases. For each test case, enter the indicated values for Order amount and Sales tax percent; click the Calculate Total Including Tax button; and check that the messages displayed in the list box are correct. Capture a screenshot showing the results of each correct test case and paste it into a Word document. Remember to use CTRL+ALT+PrintScreen to capture a screenshot.
|
Test case # |
Order amount |
Sales tax percent |
Messages |
|
1 |
abc |
def |
Please enter a numeric order amount. Please enter a numeric sales tax percent. |
|
2 |
-1 |
0.15 |
Please enter an order amount greater than 0. Please enter a sales tax percent between 0 and 0.14. |
|
3 |
100.00 |
0.10 |
The sales tax is $10.00. The total including tax is $110.00. |
As an example, the screenshot for Test Case 1 should look as follows.
(c) If your application does not work correctly, debug the application and try again. Post in the Q & A Forum or contact your professor for assistance, if needed.
(d) When your application works correctly for all test cases, select and copy all the code for the button-click event handler, the ValidateOrderAmount function, and the ValidateSalesTaxPercent function, and paste it into your Word document below the three test case screenshots. Save the Word document as Lab5YourFirstLastName.docx (where YourFirstLastName = your first and last name; e.g., JohnSmith) and submit it to the appropriate dropbox.
