Enum Traffic Light with if
easyQuestion 155Use a Java enum and an if statement to determine and print the action for a traffic light.
The enum Light is already declared. Set the current light to Light.GREEN, then use if to check: print 'Go' if GREEN, otherwise print 'Stop'. With enums, always use == for comparison, not .equals().
Expected output
Go= newline. The output ends with a newline, so print one after the last line.
Hints3 available
Sign in to use hintsTopics
Miscellaneous
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.