Question: The normal behavior for a stop light is to cycle from Red to Green to Yellow to Red (and continues with this pattern). Write a

The normal behavior for a stop light is to cycle from Red to Green to Yellow to Red (and continues with this pattern). Write a java program TrafficLightChecker.java, which will determine the next color of a stop light in this pattern, Red to Green to Yellow to Red based on the current stop light provided by the user. Task You must implement the following using a suitable if decision statement. 1. Have the user enter the value for the currentColor. 2. Compute the next color stop light based on the currentColor. 3. Alert the user for any invalid value of color. Expected Output: a. Enter a color code 1 Next Traffic Light is green b. Enter a color code 3 Next Traffic Light is red c. Enter a color code 0 Invalid color d. Enter a color code 4 Invalid color The TrafficLightChecker.java file is available to help you get started.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!