ETH官方钱包

切換
舊版
前往
大廳
主題

C語言:利息計算工具

查理 | 2013-09-10 09:07:20 | 巴幣 2 | 人氣 537


#include <stdio.h>

int main()
{
    float Principal;      //資金
    float Rate;             //利率
    int Days;               //天數
    float Interest;        //利息

    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= Principal* Rate *(float)Days /365;

        printf("The interest charge is $%.2f\n\n",Interest);

        printf("Enter account number (-1 to end):");
        scanf("%f", &Principal);
    }
    system("pause");
    return 0;
}

創作回應

更多創作