CS 162 Spring 2000 Assignment 5 –Vectors 100 points

Assigned: 03/06/2000

Due: 03/22/2000 (Wed) at the start of class. – but we will have a new assignment in lab on 3/21

Pre-Lab (Do Before Lab): Bring an empty (or nearly empty) disk. Plan out steps needed for program.

Pairs: You may work in pairs if you want. Note, during the course of the semester, you cannot pair with any one person more than twice. If you work in a pair, turn in ONE copy that is the work of both of you, with both of your names on it. If substantial parts of a program are taken from non-partners, that is plagiarism. The copier and copyee will each receive a zero.

Main Assignment: We are updating our Account "client" program to use vectors instead of arrays. The chief changes include:

  1. Declare a vector of accounts instead of an array
  2. If the user specified account number doesn’t exist, give them an opportunity to create that account (with a zero balance) (see below)

3) All other capabilities are as in Assignment 3 (using vectors instead of arrays) (see below).

Details:

  1. If you change account.h and/or account.cpp, make sure you hand them in as well. (I don’t think you should have to).
  2. The construction of a vector (unfortunately) sets each element to the same value – this will result in 10 identical accounts. Before you do ANYTHING, you will want to use the default Account constructor to replace these accounts with a set of accounts with different (random) account numbers.
  3. If your assignment 3 program had many bugs (score less than 90?), you may want to look at my version (posted under Student Work under my 162 class WWW page). However, make sure you understand it, don’t just start pulling out code.

Hand-in:

1) Listing of the program

2) Disk with your .cpp file and your working .exe file. NAME YOUR PROGRAM FILE yourlastname5.cpp; Name your project yourlastname5 so that the executable will be yourlastname5.exe. If you are working in pairs, use both last names.

Miscellaneous:

1) If you have any questions about what should be done, please ask!!

2) MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). Test it more than once - I will!

3) Remember: Indentation, meaningful variable names, symbolic constants, and meaningful comments.

Sample Interaction:

In this dummy bank there are only 10 valid accounts. Work with these:

Acct# 1740 Bal: 0

Acct# 9488 Bal: 0

Acct# 2455 Bal: 0

Acct# 1711 Bal: 0

Acct# 5276 Bal: 0

Acct# 1423 Bal: 0

Acct# 2216 Bal: 0

Acct# 8576 Bal: 0

Acct# 1892 Bal: 0

Acct# 7954 Bal: 0

Enter your account number: 5276

Choose:

    1. Deposit 2) Withdrawl 3) Account Balance 4) Quit

1

Please enter the deposit amount (between 1 and 2000) 200

Choose:

    1. Deposit 2) Withdrawl 3) Account Balance 4) Quit

2

Please enter the withdrawl amount (between 20 and 200) 50

Choose:

    1. Deposit 2) Withdrawl 3) Account Balance 4) Quit

3

Your Account Acct# 5276 Bal: 150

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

5

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

4

Is it time to quit the program? (y or n): n

Enter your account number: 1111

Account number does not exist, Should it be created? (y or n): n

Enter your account number: 2222

Account number does not exist, Should it be created? (y or n): n

Enter your account number: 7954

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

1

Please enter the deposit amount (between 1 and 2000) 50

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

2

Please enter the withdrawl amount (between 20 and 200) 100

Tried to withdraw more 100 than in account 50 - Sorry

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

3

Your Account Acct# 7954 Bal: 50

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

6

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

8

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

4

Is it time to quit the program? (y or n): n

Enter your account number: 4444

Account number does not exist, Should it be created? (y or n): y

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

1

Please enter the deposit amount (between 1 and 2000) 300

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

3

Your Account Acct# 4444 Bal: 300

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

4

Is it time to quit the program? (y or n): n

Enter your account number: 1740

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

1

Please enter the deposit amount (between 1 and 2000) 100

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

1

Please enter the deposit amount (between 1 and 2000) 2500

That number was invalid

Please enter the deposit amount (between 1 and 2000) 300

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

2

Please enter the withdrawl amount (between 20 and 200) 250

That number was invalid

Please enter the withdrawl amount (between 20 and 200) 50

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

3

Your Account Acct# 1740 Bal: 350

Choose:

1) Deposit 2) Withdrawl 3) Account Balance 4) Quit

4

Is it time to quit the program? (y or n): y

Updated Accounts:

Acct# 1740 Bal: 350

Acct# 9488 Bal: 0

Acct# 2455 Bal: 0

Acct# 1711 Bal: 0

Acct# 5276 Bal: 150

Acct# 1423 Bal: 0

Acct# 2216 Bal: 0

Acct# 8576 Bal: 0

Acct# 1892 Bal: 0

Acct# 7954 Bal: 50

Acct# 4444 Bal: 300

Goodbye!