ETH官方钱包

切換
舊版
前往
大廳
主題

C語言:信用額度計算工具

查理 | 2013-09-09 23:06:35 | 巴幣 2 | 人氣 568


#include <stdio.h>

int main()
{
    int accountN;            //帳號
    float beginningB;      //月初尚未付清餘額
    float totalCharges;   //此客戶在本月簽帳的款項
    float totalCredits;     //此客戶在本月已付的款項
    float creditL;            //允許的信用額度
    float NewcreditL;    //新的未付清額度


    printf("Enter account number (-1 to end):");
    scanf("%d", &accountN);

    while(accountN !=-1){
        printf("Enter beginning balance:");
        scanf("%f",&beginningB);

        printf("Enter total charges:");
        scanf("%f",&totalCharges);

        printf("Enter total credits:");
        scanf("%f",&totalCredits);

        printf("Enter credit limit:");
        scanf("%f", &creditL);
        printf("\n");

        NewcreditL =beginningB+totalCharges-totalCredits;

        if(NewcreditL>creditL){
                printf("Account     : %d\n",accountN);
                printf("Credit limit: %.2f\n",creditL);
                printf("Balance     : %.2f\n",NewcreditL);
                printf("Credit Limit Exceeded.\n\n");
                printf("Enter account number (-1 to end):");
                scanf("%d", &accountN);
        }
        else{
            printf("Enter account number (-1 to end):");
            scanf("%d", &accountN);
        }
    }
    system("pause");
    return 0;
}

創作回應

更多創作