Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Say you have a two-dimensional array called trafficLights that holds String values that can be red. yellow, green Newer traffic lights used orange instead of

image text in transcribed
Say you have a two-dimensional array called "trafficLights" that holds String values that can be "red". "yellow", "green" Newer traffic lights used "orange" instead of "yellow". The authorities want to change all "yellow" occurrences to "orange" Write a method that replaces each occurrence of "yellow" with " orange". Not all rows will have "yellow"; some will already have "orange". You can assume that each row has three elements but will not be present in any particular order. We do not know how many rows there are. To help you get started, copy the following code to write the program. But ensure that your code works for any length trafficLights array (not only for length 3 as In the example below) public static void main(String args) { String trafficLights = { {"red", "yellow", "green"), ("green", "red", "yellow"), ("red", "green", "orange"}}; 1/ ADD YOUR CODE HERE 1/ Hint: the values are String type so you can use String functions to check whether it is "yellow" or not. Second hint: You need to use nested loops (two for loops). 7 A - . = BIUS xxS/ D eam Video

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions