$28
Assignment 2
Program Design
1. The COP bank has been receiving over 100 calls per day from customers trying to setup
their pin number. Since the process is very simple, the bank has decided to eliminate the
live support and use a program instead. Even though the program should be simple, a
small malfunction may cost the bank millions of dollars. The COP bank has big faith in
you and believes you are the perfect candidate for the job. In this assignment you are to
implement the pin setup program for the COP bank.
When the program is started it prompts the user to enter an account number:
“Please enter your 8 digit account number: ”
If the user enters anything else besides an 8 digit number an error message appears
followed by the previous prompt:
“Invalid account number. Account number must be 8 digits.
Please enter your 8 digit account number: ”
When a 8 digit number is entered, the program prompts the user to choose a 4 digit pin
number:
“Please choose a 4 digit pin number: ”
If the user enters anything else besides a 4 digit number an error message appears
followed by the previous prompt:
“Invalid pin number. Pin number must be 4 digits.
Please choose a 4 digit pin number: ”
When a 4 digit pin is chosen, the user is prompted to re-enter the pin number for
verification:
“Re-enter pin number:”
If the pin format is not correct or pins do not match an error message appears followed by
a prompt:
“Pin setup unsuccessful
Please choose a 4 digit pin number: ”
If a pin number is verified a verification message appears:
“Pin setup successful!
Account #: XXXXXXXX
Pin #: XXXX
Have a nice day.”
Where XXXXXXXX is the account number and XXXX is the pin number.
Files:
You are provided with the file Assignment2.c
Complete the missing code. Do not rename the file!
Grading:
Your code will be tested with 9 regular test case inputs (10 points each) and 2
special test case inputs (5 points each)
Submission:
Submission should be done only through Blackboard.
Compiling and testing:
To compile your file make sure the Makefile and Assignment2.c files are in
the same directory. Type “make” in the terminal in the directory of the files.
If there are no compilation errors a main executable will be created.
To test your program run “./main” from the terminal in the directory of the
files.
Following are few examples that will clarify how the output should be formated.
Note: The examples also show how many newlines should be added after each
message.
----------------------------------------------------------------------------------------------------------------------------
Example 1:
----------------------------------------------------------------------------------------------------------------------------
Please enter your 8 digit account number:
12345678
Please choose a 4 digit pin number:
1234
Re-enter pin number:
1234
Pin setup successful!
Account #: 12345678
Pin #: 1234
Have a nice day.
----------------------------------------------------------------------------------------------------------------------------
Example 2:
----------------------------------------------------------------------------------------------------------------------------
Please enter your 8 digit account number:
12345678k
Invalid account number. Account number must be 8 digits.
Please enter your 8 digit account number:
12345678
Please choose a 4 digit pin number:
123s
Invalid pin number. Pin number must be 4 digits.
Please choose a 4 digit pin number:
1234
Re-enter pin number:
1234
Pin setup successful!
Account #: 12345678
Pin #: 1234
Have a nice day.
----------------------------------------------------------------------------------------------------------------------------
Example 3:
----------------------------------------------------------------------------------------------------------------------------
Please enter your 8 digit account number:
12345678
Please choose a 4 digit pin number:
1234
Re-enter pin number:
aw
Pin setup unsuccessful
Please choose a 4 digit pin number:
1234
Re-enter pin number:
1234
Pin setup successful!
Account #: 12345678
Pin #: 1234
Have a nice day.