code please_12/10/2012

// Devleop a C++ program that will determine if a department store customer has exceeded the crdit limit on a charge account
// For each customer, the following facts are availabe:
// A) Account number ( an integer)
// b) Balance at the beginning of the month
// c) Total of all credits applies to this costomer's account this month
// e) allowed crdit limit
// the program should input each of these facrts, calculate the new balance (= beginning balance + charges - crdits ) and
// determine if the new balance exceeds the customer's credit limit, For those customers whose crdit limit is exceeded,
// the program should display the customer's accont number, credit limit, new balance, and the message "Credit limit exceeded."
//===================sample 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
Last edited on
Do your own homework.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
using namespace std;

int main()
{
	int accountNumber;
	float balance,
		  charge,
		  credit,
		  creditLimit,
		  newBalance = 0.0;

	cout << "Enter account number (-1 to end) : ";
	cin >> accountNumber;

	while ( accountNumber != -1 ) {
		cout << "Enter beginning balance: ";
		cin >> balance;
		cout << "Enter total charges: ";
		cin >> charge;
		cout << "Enter total credits: ";
		cin >> credit;
		cout << "Enter credit limit: ";
		cin >> creditLimit;

		newBalance = balance + charge - credit;

		if ( newBalance >= creditLimit ) {
			cout << "Account: " << accountNumber << endl;
			cout << "Credit Limit: " << creditLimit << endl;
			cout << "Balance: " << newBalance << endl;
			cout << "Credit Limit Exceeded.";
		}

		cout << "Enter account number (-1 to end) : ";
		cin >> accountNumber;
	}
	return 0;
}
Topic archived. No new replies allowed.