Computer Science Department
The
CS1025/CS1026
Self Placement Guide
Sample Problem
The following problem represents the level of programming expertise expected
from students at the beginning of CS1025. The fundamental programming constructs
involved in this example will be reviewed
in CS1025; however, prior experience with the programming constructs is assumed.
Please note:
1. The intent of this sample problem is to provide an example of the level of programming expected from students entering CS1025.
2. The
Computer Science Department does not provide grading of solutions to this sample
problem.
Using
a high-level procedural programming language
write a program that represents some actions of a bank’s automated teller machine
as indicated by the following specifications:
a)
Assume that the
account balance is zero at the beginning of each run of the program.
b)
The main should
implement the following algorithm:
getPin
IF pin is legal
DO
displayMenu
IF menuChoice
is WITHDRAWAL then
doWithdrawal
ELSE IF menuChoice
is DEPOSIT then
doDeposit
ELSE IF menuChoice
is DISPLAY_BALANCE then
displayBalance
ELSE IF menuChoice
is TERMINATE then
displayBalance
REPORT good bye
WHILE menuChoice
is not TERMINATE
else REPORT illegal pin
Please note:
i.
Italics are used
in the algorithm to indicate modules
ii.
The algorithm is
incomplete. You should complete the algorithm (including writing algorithms for
the modules) before attempting to write the program.
c)
A legal pin
(personal identification number) is defined to be any even integer.
d)
Assume that the
withdrawal, deposit, and account balance amounts are represented in dollars
(i.e. integers).
e)
Module getPin
must give the user a
maximum of three attempts at entering a legal pin.
f)
The program must
appropriately handle the situation when a user enters a non-existent menu
choice.
g)
A user must not
be allowed to withdraw:
i.
more than the
balance in their account
ii.
a negative value
h)
A user must not
be allowed to deposit a negative value.
a)
After you have
written the program, be sure to test it with inputs representing the various
situations the program is designed to handle.