Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab 6.1-Input Validation Critical Review If a computer reads bad data as input,

ID: 3599594 • Letter: L

Question

Lab 6.1-Input Validation Critical Review If a computer reads bad data as input, it will produce bad data as output. Programs should be designed to reject bad data that is given as input Garbage in, garbage out (GIGO), refers to the fact that computers cannot tell the difference between good data and bad date. Both numbers and strings can be validated. Help Video: lab6-1.wmv The goal of this lab is to identify potential errors with algorithms and programs. Step 1: Imagine a program that calls for the user to enter a password of at least 3 alphanumeric characters. Identify at least two potential input errors. that calls for the user to enter patients' blood pressure. Blood Step 2: Imagine a pro pressure ranges are between 50 and 230. Identify at least two potential input errors. gram Step 3: Imagine a program that allows the user to enter in 7 days worth of bottle returns and then calculated the average. Examine the program and identify at least two potential imput errors Step 4: Imagine a program that allows a teacher to enter any number of test scores and then calculated the average score. Examine the program and identify at least two potential input errors.

Explanation / Answer

Step 1 :

Case : The user has to enter a password of atleast 8 alphanumeric characters.

Potential errors that are likely to happen :

a) The user enters a password which has length less than 8.

b) The user enters a password which contains only numbers or numerals.

c) The user enters a password which contains only alphabets.

Step 2:

Case : The user has to enter patients blood pressure , the value of which usually ranges between 50 and 230.

Potential errors that are likely to happen:

a) The user enters a negative value, say -100 by mistake.

b) The user enters a value of blood pressure which a patient is least likely to possess, (less than 50 and greater than 230), say 32 or 250.

c) The user enters a decimal value of blood pressure , say 70.2 by mistake.

3) Step 3

Case : The user has to enter in 7 days worth of bottle returns and calculate the average.

Potential errors that are likely to happen:

a) The user enters an alphabet instead of the expected numerical value. This error is least likely to happen.

b) The user enters the worth of bottle returns for more than 7 days or less than 7 days by mistake.

4) Step 4

Case : The teacher has to enter any number of test scores and calcuate the average.

Potential errors that are likely to happen :

a) The teacher enters any alphabet or other character instead of the expected numerical value . This is least likely to happen.

b) In the program, the user might input the number of test scores to be read , say 10 . There is a possibility that the user does not enter the corresponding correct number of test scores (may be only 9 are input by mistake) . Hence it will affect the calculation of sum of scores and in effect, the average as well.