Hi - I can't seem to make this program work, and I believe that the main issue I'm having is in reading the data from my input file. I would deeply appreciate any advice.
Here is a link to the given problem:
http://www.sci.brooklyn.cuny.edu/~ziegler/CISC1110/HW/HW7_BankAccounts.pdf
Basically:
you have been hired as a programmer by a major bank. Your first project is a
small banking transaction system. Each account consists of a number and a balance.
The user of the program (the teller) can create a new account, as well as perform deposits,
withdrawals, and balance inquiries.
Here is the program I have written so far - I've focused on reading the balance from 2d parralele arrays in a txt file and displaying it. For some reason I'm struggling in setting the integer that would correspond to withdrawal to.
// you have been hired as a programmer by a major bank. Your first project is a
// small banking transaction system. Each account consists of a number and a balance.
// The user of the program (the teller) can create a new account, as well as perform deposits,
// withdrawals, and balance inquiries.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
// declare and open the input file
ifstream infile("c:\\?\\myinput7.txt"); //comment-out for debugging
//ifstream infile("con"); //un-comment for debugging
// declare and open the output file
ofstream outfile("c:\\?\\myoutput7.txt"); //comment-out for debugging
//ofstream outfile("con"); //un-comment for debugging
void menu()
{
cout <<"Enter W for Withdrawal " << endl;
cout <<"Enter D for Deposit " << endl;
cout <<"Enter N for New Account " << endl;
cout <<"Enter B for Balance " << endl;
cout <<"Enter Q to Quit " << endl;
cout <<"Enter X to Delete Account " << endl;
}
int main ()
{
int acctnum_array[0],max_accts[0];
double balance_array[0];
bool not_done = true;
char choice;
do
{
menu();
cin>>choice;
switch (choice)
{
case 'B':
case 'b':
{
for(int i = 1; i < 50; i++)
{
infile.open ("myinput7.txt");
while (!infile);
cout<<"there was an error opening the file." <<endl;
int read_accts(int acctnum_array[], double balance_array[], int max_accts);
cout << "enter account ID : " << endl;
cout << acctnum_array[0] << endl;
cout << balance_array[0] << endl;
}
}
break;
case 'W':
case 'w':
{
for(int i = 1; i < 50; i++)
{
int w;
infile.open ("myinput7.txt");
while (!infile);
cout << "enter account ID and amount to withdraw: " << endl;
cout << acctnum_array[0] << w << endl;
cout >> "Enter amount to withdraw" << endl;
cin >> w ;
cout << endl;
cout << "remaining balance for" << acctnum_array << is << (balance_array[0]-w) << endl;
}
}
break;
case 'Q':
case 'q' :
not_done=false;
break;
default:
cout<< choice<< " is not a valid selection. Try again.";
break;
}
}
while (not_done);
return 0;
}
again, I would deeply appreciate any help that you could provid.
Thanking you all in advance.