CS 162 Spring 2000 Assignment 3 –Object-Oriented Programming with C++ - Using an existing class 100 points

Assigned: 02/14/2000

Due: 02/21/2000 at the start of class.

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. Each member of the pair will receive the same grade for that lab. In such a partnership, students must share as equally as possible the work and learning. Working together with truly shared effort and learning can be a positive experience. However, simply giving/receiving code from someone defeats the learning process. 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:

A simplified Account class has been provided (account.h and account.cpp under Review on my WWW page). Create a (very) simplified client program, as illustrated below. The program should create an array of 10 accounts, and as long as the user wants to keep playing, prompt them for an account number, and when they give a valid account number, ask them if they want to Deposit, Withdraw, or Check account balance, or quit. After each account quits, see if the general user says to quit (see below). When quitting entirely, show all 10 account balances.

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 – I don’t think you should even have to look at account.cpp)
  2. You can get the random account numbers using the default constructor.

Hand-in:

1) Listing of the program

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

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. Weaknesses in any of these could result in points off. Also make sure you put YOUR NAME(s), section, and e-mail address in comments at the beginning of the program.

Sample Interaction:

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

Acct# 3123 Bal: 0

Acct# 3411 Bal: 0

Acct# 3874 Bal: 0

Acct# 2779 Bal: 0

Acct# 3198 Bal: 0

Acct# 6502 Bal: 0

Acct# 8602 Bal: 0

Acct# 4865 Bal: 0

Acct# 0900 Bal: 0

Acct# 6138 Bal: 0

Enter your account number: 2779

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# 2779 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? n

Enter your account number: 1111

Enter your account number: 2222

Enter your account number: 6502

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# 6502 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? n

Enter your account number: 8602

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# 8602 Bal: 350

Choose:

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

4

Is it time to quit the program? y

Updated Accounts:

Acct# 3123 Bal: 0

Acct# 3411 Bal: 0

Acct# 3874 Bal: 0

Acct# 2779 Bal: 150

Acct# 3198 Bal: 0

Acct# 6502 Bal: 50

Acct# 8602 Bal: 350

Acct# 4865 Bal: 0

Acct# 0900 Bal: 0

Acct# 6138 Bal: 0

Goodbye!