0% found this document useful (0 votes)
76 views4 pages

Homework 3

The document contains C++ code for a banking program that simulates deposits and withdrawals from customer accounts. The program opens a bank data file, reads in customer IDs, transaction codes, amounts, and balances. It then displays account information and calculates transaction totals while the user performs deposits and withdrawals. If a withdrawal exceeds the available balance or the code is invalid, an error message is displayed. Once processing is complete, final totals are output for deposits, withdrawals, and net transaction amounts.

Uploaded by

api-329343291
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views4 pages

Homework 3

The document contains C++ code for a banking program that simulates deposits and withdrawals from customer accounts. The program opens a bank data file, reads in customer IDs, transaction codes, amounts, and balances. It then displays account information and calculates transaction totals while the user performs deposits and withdrawals. If a withdrawal exceeds the available balance or the code is invalid, an error message is displayed. Once processing is complete, final totals are output for deposits, withdrawals, and net transaction amounts.

Uploaded by

api-329343291
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Chloe Sebring

# include <iostream>
# include <fstream>
#include <iomanip>
using namespace std;
void main()
{
ifstream fin;
fin.open("bank.dat");

int id, code = 0;


float amt, balance = 0;

int totDep = 0;
int totWit = 0;
float totAmt = 0;
float totAmtW = 0;

fin >> id >> code >> amt >> balance;


cout << fixed << setprecision(2);

while (!fin.eof())
{ cout << endl;
cout << "Welcome Account #" << id << endl << "Your amount is $" << balance
<< endl;
if (code == 1)
{

balance = balance + amt;


cout << "You have chosen to make a deposit of $" << amt << " making
your total balance $" << balance << endl;
totDep ++;
totAmt = totAmt+ amt;

}
if (code == 2)
{
if (amt > balance)
{
cout << "Account #" << id << endl << "You wish to withdrawl $"
<< amt << ", but you do not have enough funds to withdrawl the amount asked. " << "Please
come back when you have attained $" << amt - balance << " more dollars." << endl;
}
else
{
balance = balance - amt;
cout << "You have chosen to make a withdrawl of $" << amt << "
making your total balance $" << balance << endl;
totWit++;
totAmtW = totAmtW + amt;
if (balance < 100)
{
balance = balance - 10;
cout << "Balance below minium -- $10.00 fee assessed. "
<< "This makes your total balance $" << balance << endl;
}
}

}
else if (code < 1 || code > 2)
{
cout << "It's a beautiful day outside.. the birds are singng.. the flowers
are blooming.. it's on days like this, kids like you..... SHOULD BE ENTERING IN THE RIGHT
CODE! " << endl;
}
//output global stats
fin >> id >> code >> amt >> balance;

cout << endl << "Today this bank has had " << totDep << " deposits and " << totWit
<< " successful withdrawls. Totaling: $" << totAmt << " in deposits and $" << totAmtW <<
" in withdrawls. Thank you for your service!" << endl;
system("Pause");
} # include <iostream>
# include <fstream>
#include <iomanip>
using namespace std;
void main()
{
ifstream fin;
fin.open("bank.dat");

int id, code = 0;


float amt, balance = 0;

int totDep = 0;
int totWit = 0;
float totAmt = 0;
float totAmtW = 0;

fin >> id >> code >> amt >> balance;


cout << fixed << setprecision(2);

while (!fin.eof())
{ cout << endl;
cout << "Welcome Account #" << id << endl << "Your amount is $" << balance
<< endl;
if (code == 1)
{

balance = balance + amt;


cout << "You have chosen to make a deposit of $" << amt << " making
your total balance $" << balance << endl;
totDep ++;
totAmt = totAmt+ amt;

}
if (code == 2)
{
if (amt > balance)
{
cout << "Account #" << id << endl << "You wish to withdrawl $"
<< amt << ", but you do not have enough funds to withdrawl the amount asked. " << "Please
come back when you have attained $" << amt - balance << " more dollars." << endl;
}
else
{
balance = balance - amt;
cout << "You have chosen to make a withdrawl of $" << amt << "
making your total balance $" << balance << endl;
totWit++;
totAmtW = totAmtW + amt;
if (balance < 100)
{
balance = balance - 10;
cout << "Balance below minium -- $10.00 fee assessed. "
<< "This makes your total balance $" << balance << endl;
}
}

}
else if (code < 1 || code > 2)
{
cout << "It's a beautiful day outside.. the birds are singng.. the
flowers are blooming.. it's on days like this, kids like you..... SHOULD BE ENTERING IN
THE RIGHT CODE! " << endl << "Account #" << id << ":Bad Transaction Code" << endl;
//fin >> id >> code >> amt >> balance;
}
//output global stats
fin >> id >> code >> amt >> balance;

cout << endl << "Today this bank has had " << totDep << " deposits and " << totWit
<< " successful withdrawls. Totaling: $" << totAmt << " in deposits and $" << totAmtW <<
" in withdrawls. Thank you for your service!" << endl;
system("Pause")
}

You might also like