Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are asked to create a VB application to calculate shipping charges. Differen

ID: 3836482 • Letter: Y

Question

You are asked to create a VB application to calculate shipping charges. Different rate for different weight and distance. Rates based on weights: $0, 010 per mile for 2kg or less. $0, 015 per mile for over 2kg, but not more than 6kg. $0, 020 per mile for over 6kg, but not more than 10kg. $0, 025 per mile for over 10kg, but not more than 20kg. Some restrictions: Weight must be greater than oak. Weight must not be greater than 20kg. Distance must be at least 10 miles. Distance must not be greater than 3,000 miles. Requirements for this project: Using "name constants" for 4 different rates Using "Try Parse" and "is Numeric" to validate user's input Show messages: Message Box. Show ("Weight - The value must be a real number greater than zero and less than 20.", "Invalid Input") Message Box. Show ("Distance - The value must be a real number between 10 and 3000.", "Invalid Input") Using "select case" on rate Use "focus" on the clear button Total shipping charges = Weight * Rate * Distance

Explanation / Answer

Private Sub btnCalculateRate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateRate.Click

Dim decPackageWeight As Decimal

Dim decShippingDistance As Decimal

Dim decShippingCost As Decimal

Dim decMileageCost As Decimal

decPackageWeight = Val (txtPackageWeight.Text)

If decPackageWeight > 0 and <= 20 Then

Else

MessageBox.Show("Packages must weight between 0 and 20 kgs.")

txtPackageWeight.Focus()

txtPackageWeight.SelectAll()

Exit Sub

End If

decShippingDistance = Val(txtShippingDistance.Text)

If decShippingDistance >= 10 And decShippingDistance <= 3000 Then

Else

MessageBox.Show("Packages can only delivered between 10 and 3000 miles.")

txtShippingDistance.Focus();

txtShippingDistance.SelectAll()

Exit Sub

End If

If decPackageWeight <= 2 Then

decMileage = 0.01D

ElseIf decPackageWeight > 2 And decPackageWeight <= 6 Then

decMileageCost = 0.15D

ElseIf decPackageWeight >6 And decPackageWeight <= 10 Then

decMileageCost = 0.02D

Else

decMileageCost = 0.025D

EndIf

decShippingCost = decMileageCost * decShippingDistance

lblShippingCost.Text = Format(decShippingCost, "0.00")

End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote