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

案例9 :门票价格查询
步骤:
ASP.NET--表达式、运算符与分支结构(实战案例汇总3)_第1张图片
clip_image002[5]
clip_image003[5]
clip_image004[5]
其代码如下;
{
int month = Convert.ToInt32(DropDownList1.Text);
double piaojia;
if (RadioButton2.Checked)
{
if (month &gt; 3 && month < 11)
{
piaojia = 30;
Label1.Text = Convert.ToString(piaojia);
}
else
{
piaojia = 20;
Label1.Text = Convert.ToString(piaojia);
}
}
else if (RadioButton3.Checked)
{
if (month > 3 && month < 11)
{
piaojia = 20;
Label1.Text = Convert.ToString(piaojia);
}
else
{
piaojia = 15;
Label1.Text = Convert.ToString(piaojia);
}
}
else
{
Label1.Text = "请选择游客类型";
}
}
}
clip_image005[5]
clip_image006[5]
clip_image007[5]
clip_image008[5]
clip_image009[5]
案例10 :工资个人所得税的算法
步骤:
clip_image010[5]
其代码如下;
{
double shui;
double gongzi = 0;
if (TextBox1.Text == "")
{
Label1.Text = "请输入你的工资";
}
else
{
{
gongzi = Convert.ToDouble(TextBox1.Text);
}
double shuie = gongzi - 2000;
if (shuie > 100000)
{
shui = 29625 + (shuie - 100000) * 45 / 100;
Label1.Text = Convert.ToString(shui);
}
else if (shuie &gt; 80000)
{
shui = 21625 + (shuie - 80000) * 40 / 100;
Label1.Text = Convert.ToString(shui);
}
else if (shuie &gt; 60000)
{
shui = 14625 + (shuie - 60000) * 35 / 100;
Label1.Text = Convert.ToString(shui);
}
else if (shuie &gt; 40000)
{
shui = 8625 + (shuie - 40000) * 30 / 100;
Label1.Text = Convert.ToString(shui);
}
else if (shuie &gt; 20000)
{
shui = 3625 + (shuie - 20000) * 25 / 100;
Label1.Text = Convert.ToString(shui);
}
else if (shuie &gt; 5000)
{
shui = 625 + (shuie - 50000) * 20 / 100;
Label1.Text = Convert.ToString(shui);
}
else if (shuie &gt; 2000)
{
shui = 625 + (shuie - 2000) * 15 / 100;
Label1.Text = Convert.ToString(shui);
}
else if (shuie &gt; 500)
{
shui = 25 + (shuie - 500) * 10 / 100;
Label1.Text = Convert.ToString(shui);
}
else if (shuie &gt; 0 && shuie <= 500)
{
shui = shuie * 5 / 100;
Label1.Text = Convert.ToString(shui);
}
else
{
shui = 0;
Label1.Text = Convert.ToString(shui);
}
}
}
}
clip_image011[5]
clip_image012[5]
clip_image013[5]
clip_image014[5]
clip_image015[5]
clip_image016[5]
clip_image017[5]
案例11 :积分查询
步骤:
clip_image018[5]
其代码如下;
{
int jifen = 0;
if (TextBox1.Text == "")
{
Label1.Text = "请输入你的积分";
}
else
{
{
jifen = Convert.ToInt32(TextBox1.Text);
}
if (jifen >= 10000)
{
Label1.Text = "包吃一个月的包子";
}
else if (jifen &gt;= 8000)
{
Label1.Text = "3个包子";
}
else if (jifen &gt;= 5000)
{
Label1.Text = "两个包子";
}
else if (jifen &gt;= 1000)
{
Label1.Text = "一个包子";
}
else
{
Label1.Text = "你不能兑换任何物品";
}
}
}
}
clip_image019[5]
clip_image020[5]
clip_image021[5]
clip_image022[5]
clip_image023[5]
clip_image024[5]

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