Validation_LABB

advertisement
Validation Lab B
1. A person must guess a mystery number from one to ten. They have three tries to guess the right number.
Prompt user:
a. Guess a number.
b. Guess again if the number was not correct.
Program to process:
a. While loops using else/ifs.
b. Count number of tries.
c. Stop if they run out of tries.
d. Validate that only an integer is entered.
The output:
(The number is 3.)
“Guess a number from 1 to 10!”
5 <enter>
“Guess again!”
3 <enter>
“You got it right!”
(s.c. x 2 and code)
2. The students will know their letter grade after entering a number grade.
Prompt User:
a. Enter a numeric grade in float from 1 to 100.
Program to process:
a. While loops using else/ifs
b. Give an error message if numeric isn’t entered.
The Output:
“Enter a numeric grade” 97
“Your grade letter is A+”
(s.c. x2 and code)
1
3. Enter a dollar amount between 1 to 500 dollars. Make sure inputs are valid.
Prompt user:
a. Enter from 1.00 to 500.00 dollars. (in float)
b. Enter again! (If one enters under or over the condition in “a” or a letter was entered.)
Program to process:
a. Else if to check value within range.
i. Validate that dollar is within range.
ii. Validate that no letter is entered.
The Output:
“Enter from 1.00 to 500.00 dollars.” 100
“You have entered $100.00
(s.c. x2 and code)
4. Enter five digit zip code.
Prompt user:
a. Enter a zip code in five digits:
Program to process:
a. Making sure it is up to five digits in range.
b. Validate that only numbers entered. No string allowed.
The Output:
The zip code: 12866
(s.c. x 2 and code)
2
Download