紙のコストを計算するこのプログラムがあります。まず、価格とバンドルが宣言され、初期化されます。次に、除算とモジュロを使用したif elseステートメントを使用して、バンドルを課金レートに分解します。紙の束の金額は正しく計算されていますが、総費用はオフになっています。誰かが私がここで間違っていることを見つけることができますか?
Module Paper
Sub Main()
'declare variables
Dim PaperAmountReq As Double
Dim PricePer_1_Sheet As Double = 0.1
Dim PricePer_100_Sheets As Double = 0.055
Dim PricePer_500_Sheets As Double = 0.04
Dim PricePer_1000_Sheets As Double = 0.03
Dim NumberOfSingles As Double = 0
Dim NumberOf100s As Double = 0
Dim NumberOf500s As Double = 0
Dim Numberof1000s As Double = 0
Dim TotalCost As Double
Console.Write("Enter number of sheets of paper needed: ")
PaperAmountReq = Console.Readline
If PaperAmountReq / 1000 >= 1 Then
Numberof1000s = PaperAmountReq \ 1000
PaperAmountReq = PaperAmountReq Mod 1000
End If
If PaperAmountReq / 500 >= 1 Then
NumberOf500s = PaperAmountReq \ 500
PaperAmountReq = PaperAmountReq Mod 500
End If
If PaperAmountReq / 100 >= 1 Then
Numberof100s = PaperAmountReq \ 100
PaperAmountReq = PaperAmountReq Mod 100
End If
If PaperAmountReq / 1 = PaperAmountReq Then
NumberOfSingles = PaperAmountReq
End If
'TotalCost = (Convert.ToDouble(Numberof1000s) * PricePer_1000_Sheets) + (Convert.ToDouble(NumberOf500s) * PricePer_500_Sheets) + (Convert.ToDouble(Numberof100s) * PricePer_100_Sheets) + (Convert.ToDouble(NumberOfSingles) * PricePer_1_Sheet)
TotalCost = (Numberof1000s * PricePer_1000_Sheets) + (NumberOf500s * PricePer_500_Sheets) + (Numberof100s * PricePer_100_Sheets) + (NumberOfSingles * PricePer_1_Sheet)
Console.WriteLine("Number of 1000 packages: " & Numberof1000s)
Console.WriteLine("Number of 500 packages: " & Numberof500s)
Console.WriteLine("Number of 100 packages: " & Numberof100s)
Console.WriteLine("Number of singles packages: " & NumberOfSingles)
Console.Write("Total Cost: " & TotalCost)
End Sub
エンドモジュール