I already have most of the code for this following program
Write a program that loads bank balance information from a file and then allows transactions
against those accounts. Finally, save the account info back out to the file.
o When the program starts, ask the user for the account file they want to
o Read the file the user indicated – it consists of ids, names and dollar amounts – you can
assume that all the names will be one word!
o Create three parallel arrays to store the account info (one of account id’s (int), one of
names (string) and one of account balance (float) ) – assume a maximum number of
entries of 50 (use a const variable to contain this number).
o Write a menuing system with the following options:
(M)odify amount – ask the user for an id and an amount to modify by – report
back to the console the name and current balance after modification
(R)eport – write out all account info for all accounts
(E)xit and save – exit the menu loop and save the accounts back to the
accounts.txt file
o Make sure you can load that accounts.txt file again by running the program again.
o Write the following functions:
int loadData( string filename, int ids[], string names[], float balances[] );
• load all data from file filename into the passed in arrays – return the
number of accounts read
int getIndex( int theID, int ids[], int numAccounts );
• go through the passed in array of ids and find the index of passed in id.
Return that index. Return -1 if not found.
void modifyBalance( int index, float balances[], float amount);
• modify the balance in balances at the index by the amount passed in
void reportAccountInfo( int index, int ids[], string names[], float balances[] );
• write to the console the id, name, and balance for the given account
index
void reportAllAccountInfo( int ids[], string names[], float balances[], int
numAccounts);
• write to console account info for all accounts
void saveAccounts(string filename, int ids[], string names[], float balances[], int
numAccounts );
• write to filename file all account info
o Create a separate .cpp/.h pairing called functions.h/.cpp for all your functions and
prototypes.
Im just very stuck on the functions part of it my professor hasnt done very well at teaching us functions but this the code that I have so far..
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
o Write the following functions:
int loadData( string filename, int ids[], string names[], float balances[] );
• load all data from file filename into the passed in arrays – return the
number of accounts read
int getIndex( int theID, int ids[], int numAccounts );
• go through the passed in array of ids and find the index of passed in id.
Return that index. Return -1 if not found.
void modifyBalance( int index, float balances[], float amount);
• modify the balance in balances at the index by the amount passed in
void reportAccountInfo( int index, int ids[], string names[], float balances[] );
• write to the console the id, name, and balance for the given account
index
void reportAllAccountInfo( int ids[], string names[], float balances[], int
numAccounts);
• write to console account info for all accounts
void saveAccounts(string filename, int ids[], string names[], float balances[], int
numAccounts );
• write to filename file all account info
o Create a separate .cpp/.h pairing called functions.h/.cpp for all your functions and
prototypes.
1) Create a header file called functions.h, which contains the prototypes (i.e. declarations) of all the functions you need to write. This should be trivially easy.
2) Create a source file called functions.cpp, which contains the definitions of all those functions - i.e. the code for what they actually do.
3) Call those functions from your main function, as appropriate.