參考答案:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSD01
{
class Program
{
static void Main(string[] args)
{
// TODO
try
{
string type;
double price;
Console.Write("請輸入購買者會員種類>");
type = Console.ReadLine();
Console.Write("請輸入商品原始金額>");
price = double.Parse(Console.ReadLine());
switch (type)
{
case "A":
price *= 0.8;
break;
case "B":
price *= 0.9;
break;
default:
break;
}
Console.WriteLine("該商品售價應為{0:0.00}",price);
}catch(Exception)
{
Console.WriteLine("輸入錯誤,請重新執行");
}
Console.ReadLine();
}
}
}
執行結果:
留言列表