EET/SSE/CPE 2350
HW # 3
Validate Input and Error Checking
(Submit 4 C programs via text file with comments)
(Submit 8 screenshots in .doc file; one screenshot for “entry correct” and “entry incorrect”; 2 screenshots per program)
Objective:
The purpose of this HW is to establish that what a user is entering is what is requested. If the program asks for a letter, does the user enter a letter or something else? If the user does add something different that what was requested, what does the program do: proceed as if everything is ok, stop, ask for a new entry, etc.?
And, if the user continues to enter the wrong response, how many times does the program allow that and how does it respond? Finally, we must ask the questions that if there are entry problems: is our request vague, how can we help the user to answer correctly, etc. How will you as the programmer know?
At this point in the course, we are only dealing with keyboard entries but what happens when we are dealing with a database? We must be able to detect error wherever and whenever it occurs.
This has implications for us when we anticipate the 4 data files of the Final. How can we determine letters from integers? How can we determine the differences between ASCII elements?
Therefore, our objectives are:
· To write a program that clearly asks for a specific entry (Explain rationale)
· To determine that the user entry is what we want by some “test”
· To determine how many times we allow the user to enter something
· And to determine how to help the user make the right entry.
In the design of these programs, you must clearly comment what you are doing so it is clear to an observer what your logic is on a step by step basis.
Design Step 1:
Define 4 programs requesting
specific types of entry requests via keyboard:
1. “Please enter a
specific
letter” and verify that that letter was entered
2. “Please enter a
specific
hexadecimal number” and verify that a hexadecimal number was entered (see Lecture 8 for hint on this specific program)
3. “Please enter a
specific
string” and verify that that string was entered
4. Enter a
specific integer value and verify that that integer was entered.
Design Step 2:
Explain the efficacy of your entry question (is it clear? Etc.)
Design Step 3:
Explain your test to determine if the right entry was made; why did you choose it?
Design Step 4:
Explain how many tests of entry you will allow and why that amount
Design Step 5:
How can you help the user make the right entry?
Design Step 6:
4 codes x 2:
Provide code with the right entry and screenshot
Provide code with the wrong entry and screenshot