任何人都可以验证我的VISUAL BASIC应用程序吗? [英] Can anyone verify my VISUAL BASIC application?
问题描述
关于教科书的问题: 创建一个SandwichOrder应用程序,通过提示用户提供三明治(小或大)的大小和生菜,番茄,洋葱,芥末,蛋黄酱,奶酪)。一个小三明治是2.50美元,一个大三明治是4.00美元。芥末和蛋黄酱是免费的,生菜和洋葱每个0.10美元,番茄是0.25美元,奶酪是0.50美元。默认值应该是一个没有固定的小三明治。
我尝试过:
具体来说,这是一个逻辑错误。比方说,例如,我选择了三明治大小,并希望番茄和奶酪作为我的定价。所有加起来共计4.75美元。但是当我调试我的应用程序时,它会显示4.50美元而不是......有什么我做错了吗?
Question on the textbook: Create a SandwichOrder application that creates a sandwich order by prompting the user for the size of the sandwich (small or large) and the fixings (lettuce, tomato, onion, mustard, mayonnaise, cheese). A small sandwich is $2.50 and a large sandwich is $4.00. Mustard and mayonnaise are free, lettuce and onion are $0.10 each, tomato is $0.25, and cheese is $0.50. The defaults should be a small sandwich with no fixings.
What I have tried:
To be specific, it's a logical error. Let's say for example, I selected large for the sandwich size and wanted tomato, and cheese as my fixings. All add up to a total of $4.75. But when I debug my application, it displays $4.50 instead... Is there something I'm doing wrong?
Const SMALL As Decimal = 2.5
Const LARGE As Decimal = 4.0
Const LETTUCE As Decimal = 0.1
Const ONION As Decimal = 0.1
Const TOMATO As Decimal = 0.25
Const CHEESE As Decimal = 0.5
Dim numToppings As Integer = 0
Dim toppingsPrice As Decimal
Dim pizzasPrice As Decimal
If Me.chkLettuce.Checked = True Then
numToppings += 1
toppingsPrice = LETTUCE
End If
If Me.chkOnion.Checked = True Then
numToppings += 1
toppingsPrice = ONION
End If
If Me.chkTomato.Checked = True Then
numToppings += 1
toppingsPrice = TOMATO
End If
If Me.chkCheese.Checked = True Then
numToppings += 1
toppingsPrice = CHEESE
End If
If Me.radSmall.Checked = True Then
pizzasPrice = SMALL
End If
If Me.radLarge.Checked = True Then
pizzasPrice = LARGE + toppingsPrice
End If
Me.lbltotalprice.Text = pizzasPrice
推荐答案
2.50和一个大三明治是
2.50 and a large sandwich is
4.00。芥末和蛋黄酱是免费的,生菜和洋葱是
4.00. Mustard and mayonnaise are free, lettuce and onion are
每个0.10,番茄是
这篇关于任何人都可以验证我的VISUAL BASIC应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!