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
|
int main()
{
ifstream fin("data.txt");
if (!fin)
{
cout << "could not open file" << endl;
return 1;
}
int account;
double balance;
char action;
double amount;
fin >> account >> balance;
cout << "Account number: " << account;
cout << "\n\nOpening balance: R" << balance << "\n" << endl;
cout << "Transaction Amount Balance" << endl;
while (fin >> action >> amount) {
switch (action)
{
case 'W':
transaction(balance, "Withdrawal", amount, true);
break;
case 'D':
transaction(balance, "Deposit", amount, false);
break;
case 'I':
transaction(balance, "Interest", amount, false);
break;
default:
transaction(balance, "** UNKNOWN **", amount, true);
}
}
transaction(balance, "Banking Costs", 25.00, true);
cout << "\nClosing balance: R" << balance << endl;
return 0;
}
|