I am in IT/210 and am having problems with the entire class. But what I am stuck on is as follows:


Consider the following 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?"

What will be printed of the input is 0?
What will be printed if the input is 100?
What will be printed if the input is 51?
What will be printed if user enters "Winding"?
Is this design robust? If so, explain why. If not, explain what you can do to make it robust.
How many levels of nesting are there in this design?
Give one set of values that will test the normal operation of this program segment.

Defend your choices.
Give a set of test values that will cause each of the branches to be executed.
Give a set of test values that the test abnormal operation of this program segment.

I'm not understanding how to do this. Can someone please help me? Is there a web site one can go to to get assistance with these types of problems?
Thank you

I can help you understand and answer these questions. The problem you have provided is a conditional statement that checks the input value (X) and produces different outputs based on its value. Let's go through each question one by one:

1. What will be printed if the input is 0?
If the input is 0, the condition (<0=X and X<49) will be true, and the output "you fail" will be printed.

2. What will be printed if the input is 100?
If the input is 100, the condition (85<=X and X <100) will be true, and the output "your grade is 100" and "you did great" will be printed.

3. What will be printed if the input is 51?
If the input is 51, the condition (50 <=X and X < 70) will be true, and the output "your grade is 51" and "you did OK" will be printed.

4. What will be printed if the user enters "Winding"?
If the user enters "Winding" as input, it is not a valid integer value, so the program will likely produce an error or behave unexpectedly. The output cannot be determined in this case.

To get assistance with these types of problems, you can try the following resources:
- Consult your textbook or lecture materials to understand the concepts and principles of programming.
- Look for online tutorials or programming forums to find explanations and solutions to similar problems.
- Seek help from your instructor or classmates during class or office hours.
- You can also ask specific questions on online programming communities like Stack Overflow.

Now let's address the remaining questions:

5. Is this design robust? If so, explain why. If not, explain what you can do to make it robust.
This design is not fully robust because it assumes the input will always be an integer within the range of 0 to 100. To make it more robust, you can include error handling mechanisms to handle unexpected input, such as checking if the input is a valid integer before proceeding with the conditional statements or providing appropriate error messages.

6. How many levels of nesting are there in this design?
The given design has only one level of nesting, which is encapsulated within the if-else statements.

7. Give one set of values that will test the normal operation of this program segment.
To test the normal operation of this program segment, you can use the following set of test values: 0, 51, 80, and 99. These values cover all the different conditional branches provided in the statements.

8. Give a set of test values that will cause each of the branches to be executed.
To execute each branch, you can use the following set of test values:
- For the "you fail" branch: -10 and 25.
- For the "you did OK" branch: 50 and 60.
- For the "you did well" branch: 70 and 80.
- For the "you did great" branch: 85 and 95.

9. Give a set of test values that test abnormal operation of this program segment.
To test abnormal operations, you can use the following test values:
- Non-integer input: "Winding" or "ABC".
- Input less than 0: -5.
- Input greater than 100: 105.

Remember, testing different scenarios helps identify potential issues and improve the robustness of your code.

I can help you with your questions. Let's go through each one step by step:

1. What will be printed if the input is 0?
In this case, since the input (X) is equal to 0 and it falls within the range of <0-49, the output would be "you fail". The final output would be "how did you do?"

2. What will be printed if the input is 100?
If the input (X) is equal to 100, it falls within the range of 85<=X<100. Therefore, the output will be "your grade is 100" and "you did great". The final output would be "how did you do?"

3. What will be printed if the input is 51?
If the input (X) is 51, it falls within the range of 50<=X<70. Therefore, the output will be "your grade is 51" and "you did OK". The final output would be "how did you do?"

4. What will be printed if the user enters "Winding"?
The program is designed to accept an integer input for X, not a string value like "Winding". If the user enters "Winding" or any non-integer value, the program may encounter an error or unexpected behavior.

5. Is this design robust? If so, explain why. If not, explain what you can do to make it robust.
The design is not robust because it does not handle cases where the input is not an integer or falls outside the range of 0-100. To make it robust, you could add input validation to check if the input is a valid integer within the specified range before applying the if-else conditions.

6. How many levels of nesting are there in this design?
There are four levels of nesting in this design, corresponding to the if-else statements.

7. Give one set of values that will test the normal operation of this program segment.
To test the normal operation, you can use X values within the given ranges:
- X = 30: This will test the "you fail" branch.
- X = 60: This will test the "your grade is X" and "you did OK" branches.
- X = 80: This will test the "your grade is X" and "you did well" branches.
- X = 95: This will test the "your grade is X" and "you did great" branches.

8. Give a set of test values that will cause each of the branches to be executed.
To test each branch, you can use the following values:
- X = 0: This will execute the "<0=X and X<49" branch ("you fail").
- X = 50: This will execute the "50 <=X and X < 70" branch ("your grade is X" and "you did OK").
- X = 70: This will execute the "70<=X and X <85" branch ("your grade is X" and "you did well").
- X = 85: This will execute the "85<=X and X <100" branch ("your grade is X" and "you did great").

9. Give a set of test values that test abnormal operation of this program segment.
To test abnormal operations, you can use the following values:
- X = -1: This will test the lower boundary case where X is below the valid range. It should output an error or handle the case appropriately.
- X = 101: This will test the upper boundary case where X is above the valid range. It should output an error or handle the case appropriately.
- X = "abc": This will test a non-integer input. It should output an error or handle the case appropriately.

For further assistance with these types of problems, you can try searching online for resources related to conditional statements, programming exercises, or programming forums where you can ask for help.