<script runat="server">
protected void Page_Load(object sender, EventArgs e) {
//變數 price 代表物品單價, amount 代表數量, discount 代表折扣
int price, amount, discount;
protected void Page_Load(object sender, EventArgs e) {
//變數 price 代表物品單價, amount 代表數量, discount 代表折扣
int price, amount, discount;
//物品單價為 400 元
price =400;
price =400;
//假設要購買 50個
amount = 50;
if (amount < 10)
{
discount = 10;
} else if (amount >= 10 & amount < 20)
amount = 50;
if (amount < 10)
{
discount = 10;
} else if (amount >= 10 & amount < 20)
{
discount = 9;
}
else if (amount >= 20 & amount < 30)
discount = 9;
}
else if (amount >= 20 & amount < 30)
{
discount = 8;
}
else
discount = 8;
}
else
{
discount = 6;
}
discount = 6;
}
Response.Write("物品單價為" + price + "元, 您要購買" +
amount + "個, 折扣為" + discount + "折, 價格為" +
price * amount * discount / 10);
}</script>
amount + "個, 折扣為" + discount + "折, 價格為" +
price * amount * discount / 10);
}</script>
沒有留言:
張貼留言