Okey我的问题是,当你运行这个时,你没有得到每月catergory没有金额可以有人告诉我我做错了。因为如果你输入allen的名称和代码1月销售应该是500和佣金应该是1005.我无法弄清楚我做错了什么。
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= " & monthlySales + totalSales)
End Sub
结束模块
答案 0 :(得分:4)
在计算中使用之前,您没有为monthlySales
分配金额。
也许你的意思是使用那些:
Select Case salesmanCode
CASE 1
monthlySales = 500
....
End Select
SalesPersonCommission = CInt(0.01 * monthlySales + 1000)
根据您尝试做的具体操作,您可能希望在括号中包围部分计算,以清楚地指明您希望计算发生的顺序。下面的第一个计算给出了与第二个不同的结果:
SalesPersonCommission = CInt(0.01 * (monthlySales + 1000))
SalesPersonCommission = CInt((0.01 * monthlySales) + 1000)
第二个是你想要的。
答案 1 :(得分:2)
您似乎忘记设置monthlySales
。
如果您将其设置为500,则会得到您所说的预期结果。