私はビジュアルベーシックでケースを使用する必要がある質問に答えようとしています。ケースを働かせる方法
質問です:
はこの週労働時間数のユーザーと賃金の彼らの時給を要求するプログラムを書きます。このプログラムは、草の根の賃金を計算することです。労働時間数が40時間を超える場合、余分な時間は料金の1.5倍で支払われます。時間数が0〜60の範囲でない場合、プログラムにエラーメッセージが表示されます。
ここには、私が書いたコードがあります。最初の
Console.WriteLine("This will calculate the gross profit from the hours you work and the hourly pay")
Console.WriteLine("Your work hours can not be under 0 or above 60,
if you work above 40 hours the extra hours will be 1.5 times the original")
Console.Write("Please enter the hours you work a week: ")
Dim hours As Integer = Console.ReadLine()
Console.Write("Please enter the hourly pay you get: ")
Dim hourlyPay As Decimal = Console.ReadLine()
Dim message As String = "Your gross pay per week is: £"
Dim weeklyPay As Decimal
Select Case hours
Case 0 < hours < 40
weeklyPay = hours * hourlyPay
Case hours > 40 And hours < 60
weeklypay = ((40 * hourlyPay) + ((hours - 40) * (hourlyPay * 1.5)))
Case hours < 0 Or hours > 60
message = "Sorry the hours you entered are above the range try again"
End Select
Console.WriteLine(message & weeklyPay.ToString("N2"))
Console.ReadLine()
どのように我々は何が悪かったのかを知ることになっていますか? –
[Select Case Docs](https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/select-case-statement)および[Select Case Statement](https:// msdn.microsoft.com/VBA/Language-Reference-VBA/articles/select-case-statement)また[ask]を読んで[tour]を取ってください。また、Option Strictを有効にしてください – Plutonix
あなたの入力に「ABC」と入力するとどうなりますか?整数/小数点は文字列ではないことを覚えておいてください。そして、コンパイラでリレーしないでください。 Option Strict On – Steve