Answer:
Please find the program in attachment.
The sample program is self explanatory, and with all the functions being listed as shown above.
And the sample program can be extended to allow three chances for authentication, and for all with addition of a simple for loop.
Explanation:
The code is self explanatory.