In Visual Basic develop an app that calculates a salesperson

In Visual Basic, develop an app that calculates a salesperson\'s commission from the number of items sold. Assume that all items have a fixed price of $10 per unit. Use a \"Select...Case\" statement to implement the following sales-commission schedule:

a) Up to 50 items sold = 6% commission

b) between 51 and 100 items sold = 7% commission

c) between 101 and 150 items sold = 8% commission

d) more than 150 items solde = 9% commission

Create an app that inputs the number of items sold and contains a Calculate Button. When this button is clicked three methods shoudl be called - one to calculate gross sales, one to calculate the commission percentage based on the commission schedule above and one to calculate the salesperson\'s earnings. Earnings are defined as gross sales multiplied by commission percentage, divided by 100 (because we\'re working with a percentage value). The data returned by these threee methods should be displayed in the GUI.

Solution

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sold As Decimal
Dim per As Decimal
Dim gross As Decimal
Dim earn As Decimal
Dim res As String

\'Convert string data to decimal

sold = Val(TextBox1.Text)

\'Calculates the commission
per = CommissionPer(sold)

\'Calculates the Gross sales

gross = GrossSale(sold)

\'Calculates the Earning
earn = Earning(gross, per)

\'Concatenates message with earning

\'Converts variable earn to string

res = \"Your Earning = \" + earn.ToString

\'Displays the result
MsgBox(res.ToString, vbExclamation, \"Earning\")

End Sub

\'Function to return commission
Function CommissionPer(ByVal sold As Decimal) As Decimal
Dim per As Decimal

\'Switch case for commission

Select Case sold
Case 0 To 50.0
per = 0.06

Case 51.0 To 100.0
per = 0.07

Case 101.0 To 150.0
per = 0.08

Case Else
per = 0.09

End Select

Return per
End Function

\'Function returns the Gross sales
Function GrossSale(ByVal sold As Decimal) As Decimal
Dim gr As Decimal
gr = (sold * 10)
Return gr
End Function

\'Function returns Earning
Function Earning(ByVal gross As Decimal, ByVal Cper As Decimal) As Decimal
Dim ea As Decimal
ea = gross * Cper
Return ea
End Function
End Class

In Visual Basic, develop an app that calculates a salesperson\'s commission from the number of items sold. Assume that all items have a fixed price of $10 per u
In Visual Basic, develop an app that calculates a salesperson\'s commission from the number of items sold. Assume that all items have a fixed price of $10 per u

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site