Could someone explain how to get to the answers. I read the book from class and cannot find the answers to the last 3 problems. I am not asking for the answers, just how to figure to resolve the problem. I appreciate the help.


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

What will be printed if the user enters “Wingding”?
o Is this design robust? If so, explain why. If not, explain what you can do to make it robust.
o How many levels of nesting are there in this design?
o Give a set of values that will test the normal operation of this program segment. Defend your choices.
o Give a set of test values that will cause each of the branches to be executed.
o Give a set of test values that test the abnormal operation of this program segment

Did you post the EXACT question and code because that code will not compile due to several syntax errors.

>>What will be printed if the user enters “Wingding”?
Nothing because there is nothing in the program to accept anything from the keyboard.

o How many levels of nesting are there in this design?

Concerning this question, allow me to rearrange your seudocode so
you can see it better.

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

Some of the other questions can be answer if you make this seudocode into an actual program. Then you can test your answers.

That's still only one level of nesting -- two levels of nesting would be something like this:

if condition 1   // first nexting level
{
   if condition 2  // second nesting level
   {
     // do something
   }
} else if condition 3  // back to 1st nesting level
{

}

don't you have to use endif to every if statement? I'm not sure in VB though

I not quite sure what you are talking about. However this is how you would do a nested if in seudocode.

IF (logical-expression) THEN
   statements
   IF (logical-expression) THEN
      statements
   ELSE
      statements
   END IF
   statements
ELSE
   statements
   IF (logical-expression) THEN
      statements
   END IF
   statements
END IF

Is this supposed to be a C program or VB? I moved this thread into the C board because the code posted in the original thread looked like C code, but maybe I was wrong. Aia's post looks like VB because that's the way it would be coded in VB. If this is about VB then just say so and I'll move it again into the correct board.

Is this supposed to be a C program or VB? I moved this thread into the C board because the code posted in the original thread looked like C code, but maybe I was wrong. Aia's post looks like VB because that's the way it would be coded in VB. If this is about VB then just say so and I'll move it again into the correct board.

You could always move it to the C.Net forum. ;)
Sorry could not help it.

I am not sure. I am taking a basic IT class and this is one of the problems we were given. It seems to be clear that I do not understand this stuff. I have to change my career goals, unfortunately. I feel like a real dummy right now. Thanks for your help!!!!

I am so lost in this program as well can someone show an example of the algorithm and verification?

I am in this class as well, and the code is nothing more than pseudo code, or simple words. The class is mainly teaching program structure without actual programming language. I am also having a hell of a time in this class not being able to write and test these assignments into an actual program.

are you trying to get help?

then you should start a new thread, and remember to ask a specific question if you hope to get a specific answer.

I was just letting others know about the pseudo code, and that it is not an actual language that we are using.

I apologize, I wasn't paying enough attention, and didn't realize I was reviving such an old thread.

This question has already been answered. Start a new discussion instead.