开发者

Problem involving salesperson

开发者 https://www.devze.com 2023-02-19 03:21 出处:网络
Okey my question is when you run this you do not get no dollar amount in the monthly catergory Can someone tell me what I am doing wrong.Cause if you type in allen for name and code 1 monthly sales sh

Okey my question is when you run this you do not get no dollar amount in the monthly catergory Can someone tell me what I am doing wrong.Cause if you type in allen for name and code 1 monthly sales should be 500 and commission should be 1005. I just can not figure out what I am doing wrong.

     Option Strict On
     Option Explicit On

      Module Module1

Sub Main()

    Dim salesPersonName As String
    Dim monthlySales, SalesPersonCommission, salesmancode As Integer
    Dim totalSales, totalCommission As Integer
    Console.WriteLine("Please enter your name: ")
    salesPersonName = Console.ReadLine()
    Do While Not (salesPersonName.Equals("Eugene"))
        Console.WriteLine("Please enter a sales code: ")
        salesmancode = CInt(Console.ReadLine())
        Select Case salesmancode
            Case 1
                SalesPersonCommission = CInt(0.01 * monthlySales + 1000)
            Case 2
                SalesPersonCommission = CInt(0.03 * monthlySales)
            Case 3
                SalesPersonCommission = CInt(0.04 * monthlySales + 500)
            Case Is < 3
                SalesPersonCommission = CInt(0.02 * monthlySales + 200)

        End Select
        totalCommission = monthlySales + totalSales
        Console.WriteLine("Please enter your name= " & salesPersonName)
        Console.WriteLine("Monthly Sales= " & monthlySales)
        Console.WriteLine("Sales Code= " & salesmancode)
        Console.WriteLine("Sales Person Commission= " & SalesPersonCommission)
        Console.WriteLine("Please enter your name:")
        salesPersonName = Console.ReadLine()
    Loop
    Console.WriteLine("Total Commission Dollars= " & mont开发者_运维百科hlySales + totalSales)


End Sub

End Module


You're not assigning an amount to monthlySales before using it in the calculation.

Perhaps you mean to use those:

Select Case salesmanCode
  CASE 1
    monthlySales = 500
  ....
End Select

SalesPersonCommission = CInt(0.01 * monthlySales + 1000)

Depending on what exactly you're trying to do, you may want to surround part of your calculation in parentheses to indicate clearly what order you want the calculations to occur. The first calculation below gives a different result than the second:

SalesPersonCommission = CInt(0.01 * (monthlySales + 1000))
SalesPersonCommission = CInt((0.01 * monthlySales) + 1000)

The second is what you want.


It looks like you're forgetting to set monthlySales.

If you set it to 500 you get the results you say you're expecting.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号