Exercise: Catbots You start a company selling Catbots, cute robotic cats. You ha
ID: 3852257 • Letter: E
Question
Exercise: Catbots
You start a company selling Catbots, cute robotic cats. You have two models:
Write a program to compute the price of an order. It reports shipping cost, and total cost. The program starts like this:
Customers enter the number of each bot they want. Check that the data is numeric, and between zero and five inclusive. Show an error message if the data is bad. For example:
Shipping cost depends on the order. Orders for $1,000 or more (excluding shipping) are shipped for free. Otherwise, shipping is $4 per kilo. For example:
Use the IPO pattern, that is, separate subs for input, processing, and output.
Model Price Weight (kilos) Darth 1000 $159 1.1 SayTen 44b $299 1.9 2 3 1 Catbots Order 2 3 How many of each do you want? 4 5 Darth 1000 6 SayTen 45b 7 Compute 10 Shipping 12 TotalExplanation / Answer
Sub Button1_Click()
Dim DarthPrice As Double
Dim DarthQuantity As Integer
Dim SayTenPrice As Double
Dim SayTenQuantity As Integer
Dim Total As String
DarthPrice = 159
SayTenPrice = 299
If Not IsNumeric(Range("B5").Value) Then
MsgBox "Please enter valid number"
Exit Sub
ElseIf Range("B5").Value < 0 Then
MsgBox "Darth quantity can either be 0 or greater than 0"
Exit Sub
ElseIf Range("B5").Value > 5 Then
MsgBox "Darth quantity cannot be greater than 5"
Exit Sub
End If
If Not IsNumeric(Range("B6").Value) Then
MsgBox "Please enter valid number"
Exit Sub
ElseIf Range("B6").Value < 0 Then
MsgBox "SayTenQuantity quantity can either be 0 or greater than 0"
Exit Sub
ElseIf Range("B6").Value > 5 Then
MsgBox "SayTenQuantity quantity cannot be greater than 5"
Exit Sub
End If
DarthQuantity = Range("B5").Value
SayTenQuantity = Range("B6").Value
Total = (DarthPrice * DarthQuantity) + (SayTenPrice * SayTenQuantity)
If Total > 1000 Then
Range("B12").Value = Total
Else
Range("B12").Value = Total + Range("B10").Value
End If
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.