第六节课第三个作业(第七节课内容解答)

2018-11-08  本文已影响0人  流影随风

#编码

            Console.WriteLine("输入本金");

            string str_p = Console.ReadLine();

            Console.WriteLine("输入利率");

            string str_r = Console.ReadLine();

            Console.WriteLine("输入年份");

            string str_n = Console.ReadLine();

            try

            {

                double p = Convert.ToDouble(str_p);

                double r = Convert.ToDouble(str_r);

                int n = Convert.ToInt32(str_n);

                int i = 1;

                while (i <= n)

                {                 

                    p *= r+1;

                    Console.WriteLine("你第{0}年的钱是{1}",i,p);

                    i++;

                }

            }

            catch

            {

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

            }

          Console.ReadKey();

#效果

上一篇下一篇

猜你喜欢

热点阅读