题目:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
unsigned int account;
double beginning_balance, total_charges, total_credits, credit_limit;
cout << "Enter account numbeu(or -1 to qiut):";
cin >> account; // 输入账户
while (account != -1)
{
cout << "Enter beginning balance:";
cin >> beginning_balance; // 月初欠款
cout << "Enter total charges:";
cin >> total_charges; // 输入本月购买的所有商品的总金额
cout << "Enter total credits:";
cin >> total_credits; // 本月顾客账户存入的总金额
cout << "Enter credit limit:";
cin >> credit_limit; // 允许的信用额度
double newBalance;
newBalance = beginning_balance + total_charges - total_credits;
cout<<setprecision(2)<<fixed;
cout<<"New balance is "<<newBalance<<endl;
cout<<"Account:\t"<<account<<"\nCredit limit:\t"<<credit_limit
<<"\nBalance:\t"<<newBalance<<endl;
if (newBalance > credit_limit)
{
cout << "Credit Limit Exceeded." << endl;
}
else
{
cout << endl;
}
cout<<"\n";
cout << "Enter account numbeu(or -1 to qiut):";
cin >> account; // 输入账户
}
return 0;
}