ASP.NET--表达式、运算符与分支结构(实战案例汇总2)

案例6 :查询自动售货机中商品的价格
步骤:
clip_image002
clip_image003[1]
其代码如下;
{
if (RadioButton1.Checked)
{
Label1.Text = RadioButton1.Text + "的价格是:3万";
}
else if (RadioButton2.Checked)
{
Label1.Text = RadioButton2.Text + "的价格是:4万";
}
else if (RadioButton3.Checked)
{
Label1.Text = RadioButton3.Text + "的价格是:5万";
}
else if (RadioButton4.Checked)
{
Label1.Text = RadioButton4.Text + "的价格是:6万";
}
else
{
Label1.Text = "请选择商品";
}
}
}
clip_image004
clip_image005[1]
clip_image006
clip_image007[1]
clip_image008
clip_image009[1]
案例7 :商品打折查询
步骤:
clip_image010
其代码如下;
{
double huafei = 0;
if (TextBox1.Text == "")
{
Label1.Text = "请输入你所购物的总金额";
}
else
{
{
huafei = Convert.ToDouble(TextBox1.Text);
}
double shifu;
if (CheckBox1.Checked)
{
if (huafei >= 5000)
{
shifu = huafei * 0.55 * 0.95;
Label1.Text = shifu.ToString();
}
else if (huafei >= 2000)
{
shifu = huafei * 0.7 * 0.95;
Label1.Text = shifu.ToString();
}
else if (huafei >= 1000)
{
shifu = huafei * 0.8 * 0.95;
Label1.Text = shifu.ToString();
}
else if (huafei >= 500)
{
shifu = huafei * 0.9 * 0.95;
Label1.Text = shifu.ToString();
}
else if (huafei < 500)
{
shifu = huafei * 0.95;
Label1.Text = shifu.ToString();
}
else
{
Label1.Text = "请输入你所购物的总金额";
}
}
else
{
if (huafei >= 5000)
{
shifu = huafei * 0.55;
Label1.Text = shifu.ToString();
}
else if (huafei &gt;= 2000)
{
shifu = huafei * 0.7;
Label1.Text = shifu.ToString();
}
else if (huafei &gt;= 1000)
{
shifu = huafei * 0.8;
Label1.Text = shifu.ToString();
}
else if (huafei &gt;= 500)
{
shifu = huafei * 0.9;
Label1.Text = shifu.ToString();
}
else if (huafei < 500)
{
shifu = huafei;
Label1.Text = shifu.ToString();
}
else
{
Label1.Text = "请输入你所购物的总金";
}
}
}
}
}
clip_image011[1]
clip_image012
clip_image013[1]
clip_image014[1]
clip_image015[1]
clip_image016[1]
clip_image017[1]
clip_image018[1]
案例8 :计算并显示通话费用
步骤:
clip_image019[1]
其代码如下;
{
int shijian = 0;
if (TextBox1.Text == "")
{
Label1.Text = "请输入你的通话时间";
}
else
{
shijian = Convert.ToInt32(TextBox1.Text);
}
double huafei;
if (RadioButton1.Checked)
{
if (TextBox1.Text == "")
{
Label1.Text = "请输入你的通话时间";
}
else if (shijian > 3)
{
huafei = 0.25 + (shijian - 3) * 0.15;
Label1.Text = huafei.ToString();
}
else
{
huafei = 0.25;
Label1.Text = huafei.ToString();
}
}
else if (RadioButton2.Checked)
{
if (TextBox1.Text == "")
{
Label1.Text = "请输入你的通话时间";
}
else
{
huafei = shijian * 0.35;
Label1.Text = huafei.ToString();
}
}
else if (RadioButton3.Checked)
{
if (TextBox1.Text == "")
{
Label1.Text = "请输入你的通话时间";
}
else
{
huafei = shijian * 1.10;
Label1.Text = huafei.ToString();
}
}
else
{
if (TextBox1.Text == "")
{
Label1.Text = "请输入你的通话时间" + "请选择你的通话类型";
}
else
{
Label1.Text = "请选择你的通话类型";
}
}
}
}
clip_image020[1]
clip_image021[1]
clip_image022[1]
clip_image023[1]
clip_image024[1]
clip_image025[1]

你可能感兴趣的:(net,asp,运算符,结构,分支)