美文网首页
第六节课第三个作业(第七节课内容解答)

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

作者: 流影随风 | 来源:发表于2018-11-08 16:06 被阅读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();

#效果

相关文章

网友评论

      本文标题:第六节课第三个作业(第七节课内容解答)

      本文链接:https://www.haomeiwen.com/subject/qemwxqtx.html