CS 162 Fall 2001 Assignment 4 –Object-Oriented Programming with C++ - Using an existing class 100 points
Assigned: 09/24/2001
Due: 10/01/2001 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-new.h and account-new.cpp under Review on my WWW page). Create a (very) simplified client program, as illustrated below. The program should create an array of 15 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 15 account balances.
Details:
1) If you change account-new.h and/or
account-new.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-new.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 yourlastname4.cpp; Name your
project yourlastname4 so that the executable will be yourlastname4.exe. If you
are working in pairs, use both last names (e.g. redmondsmith4.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.
4)
Your
account numbers may not be the same as mine, but because of the way the random
number generator is seeded, your set of accounts should/will be predictably the
same every time.
Sample Interaction:
In this dummy bank there are only 15 valid accounts.
Work with these:
Acct#
3123 Bal: 0
Acct#
1285 Bal: 0
Acct#
3874 Bal: 0
Acct#
2779 Bal: 0
Acct#
7190 Bal: 0
Acct#
3198 Bal: 0
Acct#
1976 Bal: 0
Acct#
6502 Bal: 0
Acct#
4865 Bal: 0
Acct#
7531 Bal: 0
Acct#
0900 Bal: 0
Acct#
2916 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#
1285 Bal: 0
Acct#
3874 Bal: 0
Acct# 2779
Bal: 150
Acct#
7190 Bal: 0
Acct#
3198 Bal: 0
Acct#
1976 Bal: 0
Acct#
6502 Bal: 50
Acct#
8602 Bal: 350
Acct#
4865 Bal: 0
Acct#
7531 Bal: 0
Acct#
0900 Bal: 0
Acct#
2916 Bal: 0
Acct#
6138 Bal: 0
Goodbye!