Algorithm Verification

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?"


I am kinda lost on these questions can someone help me understand this and push me to the right direction.

Answer the following question about the information in Appendix J

1. What will be printed if the input is 0?

2. What will be printed if the input is 100?

3. What will be printed if the input is 51?

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

5. Is this design robust? If so, explain why. If not, explain what you can do to make it robust.

6. How many levels of nesting are there in this design?

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

8. Give a set of test values that test the abnormal operation of this program segment.

No. There is no hope for you.

Assume that x becomes whatever value the problem says is input. Then, line by line figure out what each line is doing and fill in the number 'input' for x.
What if anything is output?

this algorithm doesn't handle the case of non-integer entry, hence the question #4 and "wingding". not robust.
also, notice that it doesn't handle the case of entering 49. u need <= 49, as it is now, when u enter 49 all it will say is "how did u do?" same thing with entering 100.
and for anything over 100, it's only wishful thinking that someone will only enter 0-100, handling the error correction will make it more robust.

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.