I am wodering if i answered these correctly or not?
Algorithm Verification

Consider the following selection statement where X is an integer test score between 0 and 100.

input X

if (0 <= X and X < 49)
output "you fail"

else if (50 <= X and X < 70)
output "your grade is" X
output "you did OK"

else if (70 <= X and X < 85)
output "your grade is" X
output "you did well"

else if (85 <= X and X < 100)
output "your grade is" X
output "you did great"

endif
output "how did you do?"


1. What will be printed if the input is 0? You fail
2. What will be printed if the input is 100? Your grade is X you did great
3. What will be printed if the input is 51? Your Grade is you did OK
4. What will be printed if the user enters “Wingding”? how did you do
5. Is this design robust? If so, explain why. If not, explain what you can do to make it robust. No it is not robust; to make it robust there needs to be error messages that are displayed when the wrong integers or strings are imputed.
6. How many levels of nesting are there in this design? 1
7. Give a set of values that will test the normal operation of this program segment. Any set of numbers from 0- 100 will allow this program to operate normally. 1,50,20,32,89,99,45
8. Defend your choices. Any number that is greater than or equal to 0 and less than or equal to 100 will generate a normal operation in this program.
9. Give a set of test values that will cause each of the branches to be executed.
10. Give a set of test values that test the abnormal operation of this program segment. Any number less than 0, such as -1, or any number over 100 such as 101 and anything that is not an integer.

> 2. What will be printed if the input is 100? Your grade is X you did great
This answer is not correct. Be sure to carefully check what the boundary number is for each case.

> 4. What will be printed if the user enters “Wingding”? how did you do
This really depends on how the language in question handles input errors of that nature. ;)

> 8. Defend your choices. Any number that is greater than or equal to 0 and less than or equal to 100 will generate a normal operation in this program.
But do your numbers cover all of the cases? Normal operation should take into account any possible valid grade and test that the result is correct. That means covering all of the cases at the least. Edward would suggest the upper and lower boundary for each case.

>> 4. What will be printed if the user enters “Wingding”?

well .. what happened?? if you used scanf, i'll bet it went to crap real quick. which would not be an example of "robustness".


>> 7. Give a set of values that will test the normal operation of this program segment.

I'm pretty sure they don't want you to say "all values from 0 to 100 are valid" -- i mean, that's obvious; it's in the program specification. And you cant merely go pull values out of the air that "look good"... there needs to be a rationale as to why you pick some but not others.


>> 8. Defend your choices.

so yeah, the point here is NOT to just select all possible values... the point of software testing is that in most every real world application, you just can't reasonably test every possible combination of inputs... you'll likely have the time and resources to only test a small fraction of all possible inputs, so you have to intelligently direct the test cases to exercise some inputs but not others.

at the very least you need to select all the boundary cases, and the numbers on either side of those boundaries. because these are the cases at which typical programming errors occur.


>> 9. Give a set of test values that will cause each of the branches to be executed.

you have 4 cases (branches). pick one representative value from the approximate center of each group. combined with the boundary cases, this would be a reasonable set of test inputs to test the "expected" values, although the boundary case test should exercise each of the groups.


>> 10. Give a set of test values that test the abnormal operation of this program segment. Any number less than 0, such as -1, or any number over 100 such as 101 and anything that is not an integer.

and also non-numerics. such as "ralph" or "15X" or "1,7" etc. this is equally important as the boundary and branch values... testing these "unexpected" input values should be as thorough as possible.


.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.