= 999 and less then 1999 'postage = 15 End if 'if coupon textbox = "FREEPOST" 'postage = 0 'calculate final price with coupon discount 'create variable finalcost and start with zero value 'finalcost = saleprice + commission + postage 'if coupon textbox = "BIGSALE" 'finalcost = finalcost - finalcost*0.10 End if End sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim commission, saleprice, postcode, postage, finalcost As Double 'create commission variable and start with zero value commission = saleprice * If txtCoupon.Text = "SMALLCOMMS" Then commission = saleprice * 0.5 End If ‘handling the input saleprice = txtSalePrice.Text postcode = CInt(txtPost.Text) 'calculate postage with coupon discount If postcode < 999 Then postage = 25 ElseIf postcode >= 999 & postcode < 1999 Then postage = 15 ElseIf postcode >= 1999 & postcode < 2999 Then postage = 15 ElseIf postcode >= 2999 & postcode < 3999 Then postage = 12 End If If txtCoupon.Text = "FREEPOST" Then postage = 0 End If 'calculate final price with coupon discount finalcost = saleprice + commission + postage If txtCoupon.Text = "BIGSALE" Then finalcost = finalcost - finalcost * 0.1 End If 'transfer answer to output txtFinalCost.Text = finalcost End Sub"> = 999 and less then 1999 'postage = 15 End if 'if coupon textbox = "FREEPOST" 'postage = 0 'calculate final price with coupon discount 'create variable finalcost and start with zero value 'finalcost = saleprice + commission + postage 'if coupon textbox = "BIGSALE" 'finalcost = finalcost - finalcost*0.10 End if End sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim commission, saleprice, postcode, postage, finalcost As Double 'create commission variable and start with zero value commission = saleprice * If txtCoupon.Text = "SMALLCOMMS" Then commission = saleprice * 0.5 End If ‘handling the input saleprice = txtSalePrice.Text postcode = CInt(txtPost.Text) 'calculate postage with coupon discount If postcode < 999 Then postage = 25 ElseIf postcode >= 999 & postcode < 1999 Then postage = 15 ElseIf postcode >= 1999 & postcode < 2999 Then postage = 15 ElseIf postcode >= 2999 & postcode < 3999 Then postage = 12 End If If txtCoupon.Text = "FREEPOST" Then postage = 0 End If 'calculate final price with coupon discount finalcost = saleprice + commission + postage If txtCoupon.Text = "BIGSALE" Then finalcost = finalcost - finalcost * 0.1 End If 'transfer answer to output txtFinalCost.Text = finalcost End Sub">
Download presentation
Presentation is loading. Please wait.
Published byBertina Alexander Modified over 9 years ago
1
PRACTICE SAC 1 Some solutions
2
'inputs 'sale price 'postcode 'coupon codes 'processing 'calculate commissions (commission based on cost) 'calculate postage and handling (minus discount based on region) 'calculate various discounts (minusing the different type of discount) 'calculate final cost (involving summing all the costs) 'output: final price 'Memory ' 'saleprice double/single 'commission double/single 'postage 'discount 'finalcost
3
On event click update cost 'calculate commission with coupon discount 'create commission variable and start with zero value 'commission = saleprice*0.125 'if coupon textbox contains "SMALLCOMMS" then 'commission = commission*0.05 'end if 'finalcost = finalcost + commission 'calculate postage with coupon discount 'create commision variable and start with zero value 'if postage textbox contains < 999 'postage = 25 'else if postage textbox >= 999 and less then 1999 'postage = 15 End if 'if coupon textbox = "FREEPOST" 'postage = 0 'calculate final price with coupon discount 'create variable finalcost and start with zero value 'finalcost = saleprice + commission + postage 'if coupon textbox = "BIGSALE" 'finalcost = finalcost - finalcost*0.10 End if End sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim commission, saleprice, postcode, postage, finalcost As Double 'create commission variable and start with zero value commission = saleprice * 0.125 If txtCoupon.Text = "SMALLCOMMS" Then commission = saleprice * 0.5 End If ‘handling the input saleprice = txtSalePrice.Text postcode = CInt(txtPost.Text) 'calculate postage with coupon discount If postcode < 999 Then postage = 25 ElseIf postcode >= 999 & postcode < 1999 Then postage = 15 ElseIf postcode >= 1999 & postcode < 2999 Then postage = 15 ElseIf postcode >= 2999 & postcode < 3999 Then postage = 12 End If If txtCoupon.Text = "FREEPOST" Then postage = 0 End If 'calculate final price with coupon discount finalcost = saleprice + commission + postage If txtCoupon.Text = "BIGSALE" Then finalcost = finalcost - finalcost * 0.1 End If 'transfer answer to output txtFinalCost.Text = finalcost End Sub
4
Data Dictionary Variable NameData typeScopeDefault ValueDescription salepriceDoubleLocal100Stores sales PostcodeDoubleLocal3173Stores the postcode postageDoubleLocal0Postage cost that will be choosen Final CostDoubleLocal0The final cost will be accumulated here CommissionDoubleLocal0The commission in here
5
Other things to cover next week Testing Table Evaluation Criteria Object Descriptor
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.