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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include <iostream>
#include <iomanip>
using namespace std;
char W, D, I, Q, Z, initchar, transtype;
int balance, account, withdraw, deposit;
void instruct1 ();
void instruct2 ();
cout << fixed << showpoint << setprecision(2);
void main()
{
instruct1 ();
do
{
cout << "Enter (I)nitial account type or (Q)uit: ";
cin >> initchar;
initchar = toupper (initchar);
} while (initchar != 'Q');
if (initchar == 'I')
{
do
{
cout << "Enter account number: "; cin >> account;
cout << endl << "Enter the initial balance: "; cin >> balance;
instruct2 ();
cout << "Enter first letter of transaction type (W, D, or Z): "; cin >> transtype;
transtype = toupper (transtype);
} while (transtype != 'Z');
{
if (transtype == 'W')
{
cout << "Amount: $"; cin >> withdraw;
balance -= withdraw;
cout << "Balance for this account is now: $" << balance << endl << endl;
}
else if (transtype == 'D')
{
cout << "Amount: $"; cin >> deposit;
balance += deposit;
cout << "Balance for this account is now: $" << balance << endl << endl;
}
else
{
cout << "Illegal transaction type, re-enter";
cout << "Balance for this account is now: $";
}
}
}
else
{
cout << "Bad initial account data, re-enter: "; cin >> initchar;
initchar = toupper (initchar);
}
}
void instruct1 ()
{
cout << "SAVINGS ACCOUNT TRANSACTION PROGRAM. " << endl <<
"When prompted, enter an 'I' for the initial account " << endl <<
"information or 'Q' to terminate program execution. " << endl <<
"Then enter the account number followed by the initial " << endl <<
"account balance. All subsequent transactions are " << endl <<
"denoted as follows: " << endl << "(W) for withdrawal " << endl <<
"(D) for deposit " << endl <<
"(Z) to end account transactions for this account " << endl << endl;
}
void instruct2 ()
{
cout << "SAVINGS ACCOUNT TRANSACTION " << endl <<
"(W)ithdrawel " << endl << "(D)eposit" << endl << "(Z) to end transaction" << endl;
}
|