我要做的就是创建一个简单的薪酬计算器。用户输入他们的 baseSalary、totalSales 和 CommissionRate。该程序运行得很好,但总支付不正确。任何帮助都是极好的。这很可能是一个简单的修复,但由于这只是我的 VB 课程的第二天,我不知道如何解决这个问题。预先感谢您提供的任何帮助!
' Total Pay Calculator
' By: Jeremy Flaugher
' 01/17/2013
Module myPay
Sub Main()
' Declare the variables
Dim baseSalary As Integer
Dim totalSales As Integer
Dim commissionRate As Decimal
Dim totalPay As Integer
' Title and By line
Console.Out.WriteLine("Welcome to the Paycheck Calculator")
Console.Out.WriteLine("Created by Jeremy Flaugher" & vbCrLf)
' User Prompts
Console.Out.Write("Please enter your Base Salary: $")
baseSalary = Console.In.ReadLine()
Console.Out.Write("Please enter your number of sales: ")
totalSales = Console.In.ReadLine()
Console.Out.Write("Please enter your Commission Rate in decimal form: ")
commissionRate = Console.In.ReadLine()
' Processes
totalPay = (totalSales * commissionRate) + baseSalary
Console.Out.WriteLine("Your paycheck will total: " & (FormatCurrency(totalPay)))
Console.ReadKey()
End Sub
End Module
运行程序后,我正在检查计算器上的输出。假设我输入 100 美元作为基本工资,5 作为销售数量,0.5 作为佣金率。在计算器上,我得到了 102.5 美元的总工资,但在运行程序时,我得到了 102.00 美元。我怎样才能解决这个问题。