public void main ( ) {
Number userInputValue = 1 ; |
| |
//
Copyright 2007, R.G.Baldwin |
| // Illustrates use of if-else-if structure. |
| // Get user input. |
| userInputValue .set( value , ( NumberDialog( question = Enter an integer between 1 and 3 inclusive ) ) ); |
| // Execute the nested selection structure. |
| if ( ( userInputValue == 1 ) ) { |
| |
penguin .say( Thanks for the 1. ); duration = 30 seconds |
| } else { |
| |
if ( ( userInputValue == 2 ) ) { |
| |
penguin .say( Thanks for the 2. ); duration = 30 seconds |
| } else { |
| |
if ( ( userInputValue == 3 ) ) { |
| |
penguin .say( Thanks for the 3. ); duration = 30 seconds |
| } else { |
| |
// Code executed when userInputValue is |
| // neither 1 nor 2 nor 3. |
| penguin .say( User input error. ); duration = 30 seconds |
| } |
| } |
| } |
| } |