Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Bookmark Edit question Pseudo code Help for a Traffic Light. Please write pseudo

ID: 3816722 • Letter: B

Question

Bookmark

Edit question

Pseudo code Help for a Traffic Light. Please write pseudo code for the following situation:

- The traffic light intersection is to be green in the North/South direction for 3 seconds and green in the East/West direction for 2 seconds. In normal operationg conditions all yellow lights are 1 second long.

- Extend the problem for step #1 to include triggered left turn lanes in teh North/south directions of travel. When triggured left turn lights should be on for 1 second.

My pseudo code thus far is: If NOT green AND NOT yellow THEN red.

Thanks.

Explanation / Answer

initialize greenNS to zero
initialize redNS to zero
initialize yellowNS to zero

initialize greenEW to zero
initialize redEW to zero
initialize yellowEW to zero

initialize leftNS to zero

setup or initialize with default values

while true
   call function to change the lights or display the status of the lights according to the requirement.
   set delay time if required
  
Change lights based on requirement
   trun off greenNS
   turn on yellowNS
   turn on yellowEW
   turn off leftNS
   turn on both sides of yellow light for 1 second

   turn off yellow lights both yellowNS and yellowEW
   turn on redNS and turn off redEW
   turn on greenEW light for 2 seconds (green in the East/West direction for 2 seconds)
  
   turn on both sides of yellow lights yellowNS and yellowEW
   turn off greenEW light
   both process should be run for 2 seconds.(since yellow light should be on for 2 seconds)
  
   turn off both yellow lights are yellowNS and yellowEW
   turn off redNS and turn on redEW
   turn on greenNS light for 3 seconds (green in the North/South direction for 3 seconds)
   turn on leftNS for one second

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote