本文主要是介绍《C++大学教程》4.14信用额度问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目:
#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;
}
这篇关于《C++大学教程》4.14信用额度问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!