输入姓名打印年龄练习

   //、用户输入姓名,然后打印此人的年龄,从1岁-18岁,每一岁占一行,打印内容为“我今年xxx岁了!”;

           //当6岁时增加打印“我上小学了!”;

           //当11岁时增加打印“我上初中了!”;

          //当15岁时增加打印“我上高中了!”;

          //当18岁时增加打印“我成年了!考上了北大!”

            Console.Write("姓名:");

            string name=Console.ReadLine();

            for (int i = 1; i <= 18;i++ )

            {

                Console.WriteLine("我今年"+i+"岁了!");

                switch (i)

                {

                    case 6: Console.WriteLine("我上小学了!");

                        break;

                    case 11: Console.WriteLine("我上初中了!");

                        break;

                    case 15: Console.WriteLine("我上高中了!");

                        break;

                    case 18: Console.WriteLine("我成年了!考上北大了!");

                        break;

                }

            }

            Console.ReadLine();

原文地址:https://www.cnblogs.com/fengsantianya/p/5456548.html