我得到的输出是不是当我输入50美元时得到的输出,我应该得到58个酒吧和2个优惠券,但是当我运行它时,我得到57还剩7张优惠券。谢谢。有人能告诉我我在做什么
Module Module1
Sub Main()
' declare variable
Dim amountDollar As Integer
Dim totalCoupons As Integer
Dim leftOverCoupons As Integer
Dim numberofChocolate As Integer
Dim freeChocolate As Integer
Dim totalchocolate As Integer
Console.WriteLine("Please enter your amount here")
amountDollar = CInt(Console.ReadLine())
numberofChocolate = amountDollar
freeChocolate = CInt(numberofChocolate/7)
totalchocolate = numberofChocolate + freeChocolate
Console.WriteLine("Total number of chocolate: " & totalchocolate)
leftOverCoupons = freeChocolate Mod numberofChocolate
Console.WriteLine("Leftover Coupons: " & leftOverCoupons)
End Sub
End Module
确定这是新的,但我能做到这一点会在国防部和divison这是为什么
Sub Main()
' This program will calculate the number of chocolate bars you can buy or redeem by coupons for an input number
' of dollars. Each bar costs one dollar and there is one coupon in each bar. It takes 7 coupons to receive one
' additional chocolate bar.
Dim dollars, numberOfBars, couponCount As Integer
' Prompt user to enter amount of money they have to spend
Console.WriteLine("Would you like to buy candy bars")
Console.WriteLine("Yes")
Console.WriteLine("No")
Console.WriteLine("Please enter your amount here")
dollars = Convert.ToInt32(Console.ReadLine())
' Set value of numberOfBars and couponCount
numberOfBars = dollars
couponCount = numberOfBars
' Begin loop. Loop will determine total bars and remaining coupons
Do While couponCount >= 7
couponCount = couponCount - 7
numberOfBars = numberOfBars + 1
couponCount = couponCount + 1
Loop
' Output values for ending number of chocolate bars and remaining coupons
Console.WriteLine("The total number of chocolate bars you receive is: " & numberOfBars)
Console.WriteLine("The number of coupons you have left is: " & couponCount)
End Sub
欧凯我必须想出办法来的只是如何停止的程序,如果有人进入没有?
你需要给你更多的家庭作业规范。 50 +(50/7)当四舍五入到最接近的整数时肯定是57。 – geoffspear
嗯,我想能够得到这个输出20美元给23条和2优惠券剩下或50美元会给你留下58酒吧和2张优惠券。我一直在这一天工作。我被要求使用整数除法来确定兑换的优惠券数量,然后我将需要使用MOD来确定我将剩下多少优惠券。 – norris1023