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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started