Hi,
Just like alot of other people, I'm also new(about 2 months) to VB.NET. I have this program that your suppose to have it figure out how many chocolate bars & coupons you'll have left. I have gotten it this far but for the life of me, I'm missing something. Anyone see what I'm not doing?
Thanks
Suppose you can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. You can redeem seven coupons for one chocolate bar from the machine. You would like to know how many chocolate bars you can eat, including from those redeemed via coupons, if you have n dollars.
For example, if you have 20 dollars, then you can initially buy 20 chocolate bars. This gives you 20 coupons. You can redeem 14 coupons for two additional chocolate bars. These two additional chocolate bars give you two more coupons, so you now have a total of eight coupons. This gives you enough to redeem for one final chocolate bar. As a result you now have 23 chocolate bars and two leftover coupons.
Just like alot of other people, I'm also new(about 2 months) to VB.NET. I have this program that your suppose to have it figure out how many chocolate bars & coupons you'll have left. I have gotten it this far but for the life of me, I'm missing something. Anyone see what I'm not doing?
Thanks
Suppose you can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. You can redeem seven coupons for one chocolate bar from the machine. You would like to know how many chocolate bars you can eat, including from those redeemed via coupons, if you have n dollars.
For example, if you have 20 dollars, then you can initially buy 20 chocolate bars. This gives you 20 coupons. You can redeem 14 coupons for two additional chocolate bars. These two additional chocolate bars give you two more coupons, so you now have a total of eight coupons. This gives you enough to redeem for one final chocolate bar. As a result you now have 23 chocolate bars and two leftover coupons.
VB.NET:
Sub Main()
' define variable
Dim again As String = "y"
Dim bars, coupons As Integer
Dim money As Integer
Dim chocolatebars As Integer
Console.WriteLine("Enter Dollar Amount: ")
money = Convert.ToInt32(Console.ReadLine())
' begin outer loop for money
Do While again = "y" Or again = "Y"
Do While coupons >= 7
bars = money + coupons
chocolatebars = money \ 7
Loop
Console.WriteLine("You Get this Amount of Chocolate Bars: " & Math.Round(chocolatebars, 1))
Console.WriteLine("Do you want to do this again? (y(n)")
again = (Console.ReadLine())
Loop
End Sub