2018-11-22作业练习2

2018-11-22  本文已影响0人  邙川

Console.WriteLine("魔法师迷你游戏平台>游戏晋级");
Console.WriteLine("");
int n=1;
int count = 0;
do
{
Console.WriteLine("您正在玩第{0}局游戏,成绩为:", n);
string str_score = Console.ReadLine();
int score = Convert.ToInt32(str_score);

            if (score > 80)
            {
                count++;
            }
            n++;
            if (n > 5)
            {
                Console.WriteLine("游戏结束");
            }
            else
            {
                Console.Write("继续玩下一局游戏吗?(yes/no)");
                string answer = Console.ReadLine();
                if ("no" == answer)
                {
                    Console.Write("您已中途退出程序");
                    break;

                }
                else
                {
                    Console.WriteLine("进入下一局游戏");

                }

            }
        }
        while (n <= 5);
        double rate = count / 5.0;
        if (n > 5)
        { 
            if (rate > 0.8)
            {
                Console.WriteLine("恭喜,通过一级");
            } else if(rate > 0.6)
            {
                Console.WriteLine("通过二级");
            }else
            {
                Console.WriteLine("对不起,你未能晋级,继续加油吧~");
            }

        }else
        {
            Console.WriteLine("对不起,你没有完成游戏,不能晋级,继续加油努力");
        }
          Console.ReadKey();
上一篇下一篇

猜你喜欢

热点阅读