期中作业(4)

作业代码:

        Console.WriteLine("游戏点击率统计");

        try

        {

            string str_a = "";

            int a = 0;

            int b = 0;

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

            {

                Console.Write("第{0}个点击率是:", i);

                str_a = Console.ReadLine();

                a = Convert.ToInt32(str_a);

                if (a > 100)

                {

                    b++;

                }

            }

            Console.WriteLine("超过100的有{0}个", b);

            double c = b / 4.0;

            String d = c.ToString("P");

            Console.Write("超过100占比:{0}", d);

        }

        catch

        {

            Console.WriteLine("输入错误");

        }

        Console.ReadKey();          

你可能感兴趣的:(期中作业(4))