注册 登录
编程论坛 C++教室

各位大侠帮我看看这段程序哪里错了

菜鸟小天 发布于 2008-03-13 11:41, 493 次点击
#include<stdio.h>
#include<windows.h>
int main()
{
    float principal,rate,interest;
    int days;
    printf("enter loan principal (-1 to end):");
    scanf("%f",&principal);
    while(principal!=-1)
    {printf("enter interest rate:");
     scanf("%f",&rate);
     printf("enter term of the loan in days:");
     scanf("%f",&days);
     interest=(float)principal*rate*days/365;
     printf("the interest charge is:$%.2f\n",interest);
     printf("enter loan principal (-1 to end):");
     scanf("%f",&principal);}
     system("pause");
     return 0;}
不管输入什么数怎么输出都是31124214.00呀
2 回复
#2
PcrazyC2008-03-13 12:24
程序代码:
#include<stdio.h>
#include<stdlib.h>

int main()
{
    float principal,rate,interest;
    int days;
    printf("enter loan principal (-1 to end):");
    scanf("%f",&principal);
    while(principal!=-1)
    {
        printf("enter interest rate:");
        scanf("%f",&rate);
        printf("enter term of the loan in days:");
        scanf("%d",&days);                           //这行
        interest=(float)principal*rate*days/365;
        printf("the interest charge is:$%.2f\n",interest);
        printf("enter loan principal (-1 to end):");
        scanf("%f",&principal);
    }
    system("pause");
    return 0;
}
#3
菜鸟小天2008-03-13 12:35
3Q3Q3Q3Q3Q3Q3Q3Q
1