vanidosa27
February 22nd, 2006, 06:49 PM
I want to know if I am doing this correctly. Here is my assignment. Complete the If...Then...Else button's Click event procedure by writing an If..Then...Else statement that displays the name of the month corresponding to the number entered by the user
Example, if the user enters 1, the month is January
If the user enters an invalid number display an error message
Here is my pseudocode in If/Else and Case format:
What I am not understanding is the teacher told us to use a nested if, which is just stupid when we could use a If/ElseIf/Else?
A little help please? Thank you so much!
How can I write this pseudocode using a nested if? I don't see it as being possible.
Pseudocode for If/EsleIf/Else
1. Declare variables
2. Assign variables to the string input box
3. If the month code is 1, display January
Else If the month code is 2, display February
Else If the month code is 3, display March
Else If the month code is 4, display April
Else If the month code is 5, display May
Else If the month code is 6, display June
Else If the month code is 7, display July
Else If the month code is 8, display August
Else If the month code is 9, display September
Else If the month code is 10, display October
Else If the month code is 11, display November
Else If the month code is 12, display December
Else
Display “Error”
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Pseudocode for Case Selection Structure
1. declare variable
2. get month
3. month value:
1 display ”January”
2 display February
3 display “March”
4 display “April”
5 display “May”
6 display “June”
7 display “July”
8 display “August”
9 display “September”
10 display “October”
11 display “November”
12 display “December”
Other display “Error”
Example, if the user enters 1, the month is January
If the user enters an invalid number display an error message
Here is my pseudocode in If/Else and Case format:
What I am not understanding is the teacher told us to use a nested if, which is just stupid when we could use a If/ElseIf/Else?
A little help please? Thank you so much!
How can I write this pseudocode using a nested if? I don't see it as being possible.
Pseudocode for If/EsleIf/Else
1. Declare variables
2. Assign variables to the string input box
3. If the month code is 1, display January
Else If the month code is 2, display February
Else If the month code is 3, display March
Else If the month code is 4, display April
Else If the month code is 5, display May
Else If the month code is 6, display June
Else If the month code is 7, display July
Else If the month code is 8, display August
Else If the month code is 9, display September
Else If the month code is 10, display October
Else If the month code is 11, display November
Else If the month code is 12, display December
Else
Display “Error”
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Pseudocode for Case Selection Structure
1. declare variable
2. get month
3. month value:
1 display ”January”
2 display February
3 display “March”
4 display “April”
5 display “May”
6 display “June”
7 display “July”
8 display “August”
9 display “September”
10 display “October”
11 display “November”
12 display “December”
Other display “Error”