{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# solutions22 - CSCI-1100 Computer Science I Rensselaer...

This preview shows pages 1–3. Sign up to view the full content.

CSCI-1100 Computer Science I Rensselaer Polytechnic Institute Spring 2004 Studio 22 -- Solutions #include <iostream> #include <iomanip> #include <string> #include <fstream> using namespace std; // Create bank account data type struct acct { // bank account data int num; // account number string name; // owner of account float balance; // balance in account }; // Function Prototypes int find(acct bank[ ], int numaccts, int goal); void insert(acct bank[ ], int &numaccts, acct newacct); void remove(acct bank[ ], int &numaccts, int acctnum); int main () //PURPOSE: simulate a small bank //PRECONDITIONS: existing accounts in file account.txt // in project folder //POSTCONDITIONS: finds, inserts and deletes accounts { acct bank[1000]; // list of bank accounts int numaccts; // total number of accounts ifstream vault; // file with list of bank accounts string command; // user request int goal; // account number to find or delete int goal2; // 2 nd goal for transfer op int loc; // subscript of account in list int loc2; // subscript of 2 nd account acct account; // a bank account float amount; // amount of money // read existing accounts from file vault.open("accounts.txt"); numaccts=0; vault >> bank[0].num >> bank[0].name >> bank[0].balance; while (!vault.eof()) { numaccts = numaccts + 1; vault >> bank[numaccts].num >> bank[numaccts].name >> bank[numaccts].balance; } // display dollar values with 2 digits to right of decimal point cout << setiosflags(ios::fixed) << setprecision(2);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
// get ready to process user commands cout << "The bank is now open." ; cout << endl << endl; // loop to process user commands
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

solutions22 - CSCI-1100 Computer Science I Rensselaer...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online