Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this exercise is to demonstrate the importance of testing an application thoroughly. Open the FixIt Solution.sln file contained in the VB2017Chap04FixIt Solution

The purpose of this exercise is to demonstrate the importance of testing an application thoroughly. Open the FixIt Solution.sln file contained in the VB2017\Chap04\FixIt Solution folder. The application displays a shipping charge that is based on the total price entered by the user, as shown in Figure 4-64. Start the application and then test it by clicking the Display shipping button. Notice that the Shipping charge box contains $13, which is not correct. Now, test the application using the following total prices: 100, 501, 1500, 500.75, 30, 1000.33, and 2000. Here too, notice that the application does not always display the correct shipping charge. (More specifically, the shipping charge for two of the seven total prices is incorrect.) Open the Code Editor window and correct the errors in the code. Save the solution and then start and test the application.

Less than $1 - shipping is $0

At least $1 but less than $100 - shipping is $13

At least $100 but less than $501 - shipping is $10

At least $501 but less than $1,001 - shipping is $7

At least $1001 - Shipping is $5

' Name: FixIt Project ' Purpose: Displays a shipping charge based on a total price ' Programmer: Stewart Smith on February 8, 2020

Option Explicit On Option Strict On Option Infer Off

Public Class frmMain Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub

Private Sub txtTotal_Enter(sender As Object, e As EventArgs) Handles txtTotal.Enter txtTotal.SelectAll() End Sub

Private Sub txtTotal_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtTotal.KeyPress ' accept only numbers, the period, and the Backspace key

If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then e.Handled = True End If End Sub

Private Sub txtTotal_TextChanged(sender As Object, e As EventArgs) Handles txtTotal.TextChanged lblShipping.Text = String.Empty End Sub

Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click 'displays a shipping charge

Dim dblTotal As Double Dim intShipping As Integer

Double.TryParse(txtTotal.Text, dblTotal)

Select Case dblTotal Case Is < 100 intShipping = 13 Case 100 To 500 intShipping = 10 Case 501 To 1000 intShipping = 7 Case Else intShipping = 5 End Select

lblShipping.Text = intShipping.ToString("C0") End Sub End Class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions