Question: . Progam# 3 : Simple Traffic Light Simulator Write a program that simulates simple Traffic Light as follows. Imagine a pedestrian waiting at a traffic
Progam#: Simple Traffic Light Simulator
Write a program that simulates simple Traffic Light as follows.
Imagine a pedestrian waiting at a traffic light. The pedestrian must decide
whether it's safe to cross based on the color of the traffic light and whether a
"Walk" signal is on or off. The traffic light can be "green", "yellow", or "red", and
the "Walk" signal can be on or "off".
Asks the user to input the color of the traffic light greenyellow or red
Asks the user if the "Walk" signal is on or off
Decides and prints out what the pedestrian should do: WaitGet Ready" or
Cross
Rules:
If the traffic light is green and the "Walk" signal is on print Cross
If the traffic light is green and the "Walk" signal is off, print Wait
If the traffic light is yellow, regardless of the "Walk" signal, print Get
Ready"
If the traffic light is red, regardless of the "Walk" signal, print Wait
If the use types an invalid input, display an Input Error message
HINTs:
Use Boolean expressions with andor to combine conditions.
Ensure the program handles different inputs robustly, including case
sensitivity for the inputs eg "Green", "green", "GREEN" should all be
treated the same Same applies of on & offOn ON on Off, OFF, off
Use the lower to convert all to lower case!
lower explained:
color inputenter color: lower will convert whatever is
typed to lower case. If user types GReeN, it will be
converted to green. This way, you only have to compare
the choicecolor with green instead of trying all possible
loweruppercase combination.
Display a Menu and handle the case if the user type an invalid choice.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
