Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <iostream>
- using namespace std;
- const int maxaccounts = 10;
- unsigned accountnumber [maxaccounts];
- double balance[maxaccounts];
- void process (unsigned &accountnumber,double &balance);
- void init (unsigned &accountnumber, double &balance);
- main()
- {
- int noaccounts = 0;
- while (noaccounts < maxaccounts)
- {
- char transactiontype;
- cout << "ENTER C TO CONTINUE OR X TO EXIT ";
- cin >> transactiontype;
- if (transactiontype=='x' || transactiontype== 'x')
- {
- break;
- }
- init (accountnumber [maxaccounts],balance [maxaccounts]);
- process (accountnumber[maxaccounts], balance [maxaccounts]);
- noaccounts++;
- }
- double total = 0;
- cout << "ACCOUNT INFORMATION: \n";
- for (int i = 0; i<noaccounts; i++)
- {
- cout << "BALANCE FOR ACCOUNT"
- << accountnumber [i]
- << "="
- << balance[i]<<"\n";
- total = balance[i];
- }
- cout <<"BALANCE FOR ALL ACCOUNTS= "
- << total << "\n";
- getch();
- }
- void init (unsigned &accountnumber,double&balance)
- {
- cout <<" ENTER ACCOUNT NUMBER: ";
- cin >> accountnumber;
- balance = 0.0;
- }
- void process (unsigned &accountnumber,double & balance)
- {
- cout << "ENTER POSITIVE NUMBER FOR DEPOSIT \n"
- << "NEGATIVE FOR WITHDRAWAL \n ";
- double transaction;
- do {
- cout << ":";
- cin >> transaction;
- if (transaction > 0)
- {
- balance += transaction;
- }
- if (transaction < 0)
- {
- transaction=-transaction;
- if (balance < transaction)
- {
- cout << "INSUFFICIENT FUNDS FOR BALANCE"
- << balance
- << "CHECK"
- << transaction << "\n";
- }
- else
- {
- balance = transaction;
- }
- }
- }while(transaction!=0);
- }
Advertisement
Add Comment
Please, Sign In to add comment