We have previously seen how we can make a decision. We simply using the If...then...Else decision structure. Now we want to take it one step further and discuss how we make more than one decision in our program. We call this decision structure a Nested If....then....Else.
Suppose we were asked to create the following program:
At a school they want a computer program that will evaluate a student's hand orientation and if it is in the "raised" position they can get called upon to answer a question. If their answer is "correct" then they are praised. If they are not "correct" then they will be thanked for their effort.
First Let's do the problem statement for this:
Assumptions
Input
Calculations
Output
Scroll down for the answer after you try to do it yourself first
At a school they want a computer program that will evaluate a student's hand orientation and if it is in the "raised" position they can get called upon to answer a question. If their answer is "correct" then they are praised. If they are not "correct" then they will be thanked for their effort.
Problem Statement
Assumptions:
1. A raised hand will allow a student to answer a question
2. A students hand can only be "raised" or not.
3. A student's answer can only be "correct" or not
Input:
1. A Student's hand Orientation
2. Whether a student is correct or incorrect
Calculations
None
Output:
1. If a student's hand is raised and then answer correctly then "Thank you
for the correct answer"
2. If a student's hand is raised and then answer incorrectly then "Thank
you for trying"
Now write the human Algorithm
Scroll down for the answer after you try to do it yourself first
Human Algorithm:
1. Input the student's hand orientation
2. If the student's hand is "raised" then Input whether the student's
is correct or incorrect
3. If the student's answer is "correct" then output "Thank you for the
correct answer"
4. If the student's answer is something else then output "Thank you for
trying
Now Create the flowchart
Scroll down for the answer after you try to do it yourself first

Now Create the VB Script
Scroll down for the answer after you try to do it yourself first
<Script language ="vbscript">
DIM HandOrientation, Answer
HandOrientation = Inputbox("What is the hand Orientation")
If HandOrientation = "Raised" then
Answer = Inputbox("What is your evaluation of the answer?")
If Answer = "Correct" Then
'<-- Notice how I indented. Indenting nested if..then..else code made it
easier to understand
Document.write "Thank you for the correct answer"
Else
Document.write "Thank you for trying!"
End If
End If
</Script>