switch_case練習

CSF践行發表於2024-08-11

        static void Main(string[] args)
        {
            double intSalary = 5000;
            bool bFlag = true;
            Console.WriteLine("請輸入張三的評點等級:");
            string strLevel = Console.ReadLine();
            switch (strLevel)
            {
                case "A":
                    intSalary += 500;
                    break;
                case "B":
                    intSalary += 200;
                    break;
                case "C":
                    intSalary += 0;
                    break;
                case "D":
                    intSalary -= 200;
                    break;
                case "E":
                    intSalary -= 500;
                    break;
                default:
                    bFlag = false;
                    Console.WriteLine("輸入有誤,程式退出!");
                    break;
            }
            if (bFlag)
            {
                Console.WriteLine("張三的工資是:" + intSalary);
            }
            Console.ReadKey();
        }