问题描述
如果此文本框的总计为:PostDiscountTextBox.Text = $ 500.00,我们如何制作Switch语句,说明如果折扣后的费用金额在0.00到999.99之间,则显示一个消息框,其中显示此金额符合条件""A-100"飞行常客里程"和确定"按钮?
If the total of this textbox is: PostDiscountTextBox.Text = $500.00, how do we make Switch statements stating that if the Post-discount Cost amount is between 0.00 and 999.99, display a message box with the message of "This amount qualifies for 'A-100' frequent flier miles" and an "OK" button?
有人会提供switch语句的示例吗?
到目前为止,我只有这个,我认为它完全没有任何意义.有人会指导我吗?谢谢.
I only have this so far, and I don't think it follows anything at all. Will someone guide me through this? Thank you.
switch (PostDiscountCostTextBox.Text)
{
case (0.00 < && PostDiscountCostTextBox.Text <= 999.00)
感谢所有提供帮助的人,但是我试图弄清楚如何使用switch语句,该语句根据一系列数值来评估折后成本(与if语句无关).是的,将提出很多案件,这是我的前两个案件.有人会友好地为我提供示例,以便我可以填写其余的案例吗?我有很多谢谢.
Thank everyone who helped, but I am trying to figure out how to use a switch statement that evaluates Post-discount Cost based on a range of numeric values (nothing about an if statement). Yes, many cases will be put, and these will be my first two cases. Will someone be kind enough to provide me an example so that I could fill the rest of my cases in? I have lots. Thank you.
如果折后费用金额在 0.00到999.99之间,则显示一个消息框,其中显示消息此金额符合'A-100'飞行常客里程".和一个确定"按钮.不得使用标题栏文本或图标.
If the Post-discount Cost amount is between 0.00 and 999.99, display a message box with the message of "This amount qualifies for 'A-100' frequent flier miles." and an "OK" button. No title bar text or icon should be used.
如果折扣后的费用金额在1,000.00到1,499.99之间,请显示一个消息框,其中显示此金额符合'B-500'飞行常客里程"的条件.和一个确定"按钮.不得使用标题栏文本或图标.
If the Post-discount Cost amount is between 1,000.00 and 1,499.99, display a message box with the message of "This amount qualifies for 'B-500' frequent flier miles." and an "OK" button. No title bar text or icon should be used.
推荐答案
这种.
以下是正确使用 switch
的示例
switch(n)
{
case 1:
cost += 25;
break;
case 2:
cost += 25;
break;
case 3:
cost += 50;
break;
default:
Console.WriteLine("Invalid selection. Please select 1, 2, or 3.");
break;
}
您的示例应转换为 if-elseif-else
语句:
Your example should be transform into if-elseif-else
statement:
if(first_case_predicate)
{
}
else if(another_predicate)
{
}
else
{
// like 'default' of switch
}
这篇关于切换语句示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!