Vous êtes sur la page 1sur 4

QUESTION

1. Develop a C++ program that will determine if a department store customer has exceeded the credit limit
on a charge account. For each customer, the following facts are available:

i. Account number
ii. Balance at the beginning of the month
iii. Total of all items charged by this customer this month
iv. Total of all credits applied to this customer’s account this month
v. Allowed credit limit

The program should input each of this facts, calculate the new balance (=ii + iii - iv), and determine if the
new balance exceeds the customer’s credit limit (v). For those customers whose credit limit is exceeded,
the program should display the customer’s account number, credit limit, new balance and the message
“Credit limit exceeded.”

Example of Input/Output:
Enter account number (-1 to end): 100
Enter beginning balance: 5394.78
Enter total charges: 1000.00
Enter total credits: 500.00
Enter credit limit: 5500.00
Account: 100
Credit limit: 5500.00
Balance: 5894.78
Credit limit Exceeded

Enter account number (-1 to end): 200


Enter beginning balance: 1000.00
Enter total charges: 123.45
Enter total credits: 321.00
Enter credit limit: 1500.00

Enter account number (-1 to end): -1


CreditCounter™
source code

/*
Name : xxx
Date : 280208
Description : Assignment
Made with Dev C++ 4.9.9.2
*/

#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main()
{//open main

int account_number;
float balance, charges, credits, limit;

//get input

cout<<"\n\t+++++++++++++++++++++++++++++++++++++++++++++++++++";
cout<<"\n\n\t\t\tCREDIT COUNTER<tm>"<<endl;
cout<<"\n\t+++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;

cout<<"\n\nEnter Account Number : "<<setiosflags(ios::fixed | ios::showpoint);


cin>>account_number;

cout<<"\n\t___________________________________________________"<<endl<<endl;

while (account_number != -1)


{
cout<<"\nEnter Early Month Balance : RM ";
cin>>balance;

cout<<"\nEnter Total Charges This Month : RM ";


cin>>charges;

cout<<"\nEnter Total Credits for This Month : RM ";


cin>>credits;

cout<<"\nAllowed Credit Limit : RM ";


cin>>limit;

//compute

balance += charges - credits;


//print output

cout<<"\n\t___________________________________________________"<<endl<<endl;

if (balance > limit)


{
cout<<"\n\t...................................................."<<endl<<endl;

cout<<"\n\t\tAccount Number : "<<account_number<<endl;


cout<<"\n\t\tCredit limit : RM "<<setprecision(2)<<limit<<endl;
cout<<"\n\t\tBalance : RM "<<setprecision(2)<<balance<<endl;
cout<<"\n\n\t\tCREDIT LIMIT EXCEEDED\n";

cout<<"\n\t...................................................."<<endl<<endl;
}

cout<<"\nEnter Account Number : ";


cin>>account_number;

cout<<"\n\t___________________________________________________"<<endl<<endl;

}
cout<<"\nInvalid Account Number. Please Try Again"<<endl<<endl;
cout<<endl;

system ("pause");
}//end main
console application

Vous aimerez peut-être aussi