You have no guarantees about the accuracy of the input from the user. You have to check all input and give helpful error messages to assist the user. In particular you must ensure that the user does not enter more data than your program is able to safely accept, i.e. you must prevent buffer over?ows. If the user enters valid input then the program should behave exactly as the program in Part I with the exception that the user has to press return/enter after typing in his or her UPI.
You also have to include a function in your program named promptInput which is called twice (using JSR). The promptInput function takes three parameters:
1. the address of the prompt string e.g. "Enter your upi: "
2. the address of the buffer to hold the typed input
3. the length of the buffer (this will have to be 1 more word than the expected maximum number of characters the user will type), why?
The function should return a value of 0 to its calling context if the input ?ts in the buffer or -1 if the user types in too many characters.
As soon as the user types more characters than can ?t in the buffer your program should respond with the message "You have entered too many characters, you must start again." This message appears without the user having to type return/enter. It appears on a new line and after this the program once again prompts the user either for a UPI or an age (depending on what the user was doing at the time of the buffer over?ow).
Once the UPI has been entered in the promptInput function it then needs to be checked for validity. A valid UPI for this assignment consists of 4 lowercase alphabetical characters followed by 3 digits. If an invalid UPI is typed the program responds with the message "Invalid upi. Try again." on a new line. Then the program asks "Enter your upi: " again and the program continues.
Similarly the age needs to be checked for validity. Valid ages are any value from 0 to 999 (ok not very realistic). Only digits are valid e.g. if the user enters "_23" with the ?rst character being a space this should be rejected. If an invalid age is typed the program responds with the message "Invalid age. Try again." on a new line. Then the programs asks "Enter your age: " again and the program continues