2012-09-26 回答
一闪而过就是错了。 # include # include # include # include int main(void) { int choice,money; int sum=0; do{ clrscr(); textcolor(red); gotoxy(13,3); printf("\xdb\xdb\xdb\xdb\xb2 interest calculator \xb2\xdb\xdb\xdb\xdb"); gotoxy(2,9); printf("choose year 1:one year; 2:two year; 3:three year"); gotoxy(2,10); printf(" 4: five year; 5: eight year; 0: exit\n"); printf("please choose years deposits : \n"); scanf("%d",&choice); switch(choice) { case 1:{ int one_year(int money); printf("please input the amount of deposit :"); scanf("%d",&money); sum+=one_year(money); break; } case 2:{ int two_year(int money); printf("please input the amount of deposit :"); sleep(6); scanf("%d",&money); sum+=two_year(money); break; } case 3:{ int three_year(int money); printf("please input the amount of deposit :"); sleep(6); scanf("%d",&money); sum+=three_year(money); break; } case 4:{ int five_year(int money); printf("please input the amount of deposit :"); sleep(6); scanf("%d",&money); sum+=five_year(money); break; } case 5:{ int eight_year(int money); printf("please input the amount of deposit :"); sleep(6); scanf("%d",&money); sum+=eight_year(money); break; } case 0:break; } }while(choice!=0); sleep(6); printf("%.3d",sum); system("pause"); return 0; } int one_year(int money) { int sum,i,a; a=1; for(i=0;i<=12;i++){ a=a*1.0225; } sum=a*money; return sum; } int two_year(int money) { int sum,a,i; a=1; for(i=0;i<=12;i++){ a=a*1.0243; } sum=a*money; return sum; } int three_year(int money) { int sum,a,i; a=1; for(i=0;i<=12;i++){ a=a*1.0270; } sum=a*money; return sum; } int five_year(int money) { int sum,a,i; a=1; for(i=0;i<=12;i++){ a=a*1.0288; } sum=a*money; return sum; } int eight_year(int money) { int sum,a,i; a=1; for(i=0;i<=12;i++){ a=a*1.03; } sum=a*money; return sum; } //我看网上的回答,应该是float的问题,但不知如何解决!!!!