日期:2014-05-20  浏览次数:20948 次

求助!一个小程序问题!
在下是C#新手。做一个题时遇见问题,请各位大侠帮忙瞧瞧。
题目是:储存帐户问题,若存15000元到一个储蓄帐户,利息为5%。在每年年终时从帐户取出1000元,需要多少年这个储蓄帐户被取空。注意,如果某年年终时,余额是1000元或更少,那么该笔余额构成最后一笔取款,并且帐户被取空。


我的代码是这样的:
using   System;
using   System.Collections.Generic;
using   System.Text;

namespace   ConsoleApplication3
{
        class   Program
        {
                static   void   Main(string[]   args)
                {
                        double   yu_e=0,money   =   15000;
                        int   n   =   1;
                        while   (yu_e   >   1000)
                        {
                                money   =   money   +   money   *   0.05;
                                yu_e   =   money   -   1000;
                                n++;
                                Console.WriteLine(n);
                        }
                }
        }
}


请问下哪出问题了?

------解决方案--------------------
//练习题,练习了我,没有练习到你-_-#
//余额和总金额是同一概念
//用一个变量来代表

double money = 15000;
int n = 0;
while (money > 1000)
{
money += money * 0.05; // 增加一年的利息
money -= 1000; // 取出1000元
n++;
}
Console.WriteLine(n);