#include <stdio.h>
int main()
{
int accountN; //帳號(hào)
float beginningB; //月初尚未付清餘額
float totalCharges; //此客戶在本月簽帳的款項(xiàng)
float totalCredits; //此客戶在本月已付的款項(xiàng)
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;
}