Question Mr. Woods, an electrician for Timberland city, has made some faulty connections on eight street...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question Mr. Woods, an electrician for Timberland city, has made some faulty connections on eight street lights. The errors cause a street light to go OFF if the street lights adjacent to that light were both ON (represented as 1) or both OFF (represented as 0) on the previous night. Otherwise, the light will go ON as normal. The two street lights at the end of the road have only a single adjacent street light, so the light at the end can be assumed to be always OFF. The state of the lights on a particular day is considered for the following day, not for the same day. Because of this fault, people are having difficulty driving on the road at night. They have filed a complaint to the Head of the Federal Highway Administration. Based on this complaint the head has ordered a report of the state of street lights after M days. Write an algorithm to output the state of the street lights after the given M days. Input The first line of input consists of an 1 2 3 4560 a 7 8 GENHENGGANZHON 10 9 { 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 import java.util.*; import java.lang.*; import java.io.*; 28 29 30 31 32 33 /* */ public class Solution public static int[ { } int[] answer: // Write your return answer; public static void { Scanner in = new //input for cur int currentState int currentState for(int idx = 0; { currentState } // input for day int days = in.nex intll result ct Question Input The first line of input consists of an integer- currentState_size, representing the number of street lights (N). The next line consists of N space- separated integers- currentState, representing the current state of the street lights (i.e. either 0 or 1). The last line consists of an integer - days, representing the number of days (M). Output Print eight space-separated integers representing the state of the street lights after M days. Constraints 1 days 106 Example Input: 8 11101111 2 Output: 00000110 Explanation: The street light at position 0 has as neighboring street lights 0 O APR 30 1 2 3 4 5678 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 23 import java.util.*; import java.lang.*; import java.io.*; /* * */ public class Solution { public static int [] { } int[] answer = new int [100]; // Write your code here I return answer; street Light (int public static void main(String[] args { Scanner in = new Scanner(System.i //input for currentState int currentState_size = in.nextInt int currentState[] = new int [curre for(int idx = 0; idx < currentSta { currentState [idx] = in.nextInt } // input for days int days = in.nextInt(); intil recult = ctreetlight (currents 30 7d 123 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 22 import java.util.*; import java.lang.*; import java.io.*; /* * */ public class Solution { public static int [] streetLight (int[] current State, int days) { } int[] answer = new int [100]; // Write your code here I return answer; public static void main(String[] args) { Scanner in = new Scanner(System.in); //input for currentState 57:52 int currentState_size = in.nextInt(); int currentState[] = new int [current State_size]; for(int idx = 0; idx < currentState_size; idx++) { currentState [idx] = in.nextInt (); } // input for days int days = in.nextInt (); int [1 recult - streetlight(current state davel. ^ Question Mr. Woods, an electrician for Timberland city, has made some faulty connections on eight street lights. The errors cause a street light to go OFF if the street lights adjacent to that light were both ON (represented as 1) or both OFF (represented as 0) on the previous night. Otherwise, the light will go ON as normal. The two street lights at the end of the road have only a single adjacent street light, so the light at the end can be assumed to be always OFF. The state of the lights on a particular day is considered for the following day, not for the same day. Because of this fault, people are having difficulty driving on the road at night. They have filed a complaint to the Head of the Federal Highway Administration. Based on this complaint the head has ordered a report of the state of street lights after M days. Write an algorithm to output the state of the street lights after the given M days. Input The first line of input consists of an 1 2 3 4560 a 7 8 GENHENGGANZHON 10 9 { 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 import java.util.*; import java.lang.*; import java.io.*; 28 29 30 31 32 33 /* */ public class Solution public static int[ { } int[] answer: // Write your return answer; public static void { Scanner in = new //input for cur int currentState int currentState for(int idx = 0; { currentState } // input for day int days = in.nex intll result ct Question Mr. Woods, an electrician for Timberland city, has made some faulty connections on eight street lights. The errors cause a street light to go OFF if the street lights adjacent to that light were both ON (represented as 1) or both OFF (represented as 0) on the previous night. Otherwise, the light will go ON as normal. The two street lights at the end of the road have only a single adjacent street light, so the light at the end can be assumed to be always OFF. The state of the lights on a particular day is considered for the following day, not for the same day. Because of this fault, people are having difficulty driving on the road at night. They have filed a complaint to the Head of the Federal Highway Administration. Based on this complaint the head has ordered a report of the state of street lights after M days. Write an algorithm to output the state of the street lights after the given M days. Input The first line of input consists of an 1 2 3 4560 a 7 8 GENHENGGANZHON 10 9 { 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 import java.util.*; import java.lang.*; import java.io.*; 28 29 30 31 32 33 /* */ public class Solution public static int[ { } int[] answer: // Write your return answer; public static void { Scanner in = new //input for cur int currentState int currentState for(int idx = 0; { currentState } // input for day int days = in.nex intll result ct Question Input The first line of input consists of an integer- currentState_size, representing the number of street lights (N). The next line consists of N space- separated integers- currentState, representing the current state of the street lights (i.e. either 0 or 1). The last line consists of an integer - days, representing the number of days (M). Output Print eight space-separated integers representing the state of the street lights after M days. Constraints 1 days 106 Example Input: 8 11101111 2 Output: 00000110 Explanation: The street light at position 0 has as neighboring street lights 0 O APR 30 1 2 3 4 5678 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 23 import java.util.*; import java.lang.*; import java.io.*; /* * */ public class Solution { public static int [] { } int[] answer = new int [100]; // Write your code here I return answer; street Light (int public static void main(String[] args { Scanner in = new Scanner(System.i //input for currentState int currentState_size = in.nextInt int currentState[] = new int [curre for(int idx = 0; idx < currentSta { currentState [idx] = in.nextInt } // input for days int days = in.nextInt(); intil recult = ctreetlight (currents 30 7d Question Input The first line of input consists of an integer- currentState_size, representing the number of street lights (N). The next line consists of N space- separated integers- currentState, representing the current state of the street lights (i.e. either 0 or 1). The last line consists of an integer - days, representing the number of days (M). Output Print eight space-separated integers representing the state of the street lights after M days. Constraints 1 days 106 Example Input: 8 11101111 2 Output: 00000110 Explanation: The street light at position 0 has as neighboring street lights 0 O APR 30 1 2 3 4 5678 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 23 import java.util.*; import java.lang.*; import java.io.*; /* * */ public class Solution { public static int [] { } int[] answer = new int [100]; // Write your code here I return answer; street Light (int public static void main(String[] args { Scanner in = new Scanner(System.i //input for currentState int currentState_size = in.nextInt int currentState[] = new int [curre for(int idx = 0; idx < currentSta { currentState [idx] = in.nextInt } // input for days int days = in.nextInt(); intil recult = ctreetlight (currents 30 7d 123 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 22 import java.util.*; import java.lang.*; import java.io.*; /* * */ public class Solution { public static int [] streetLight (int[] current State, int days) { } int[] answer = new int [100]; // Write your code here I return answer; public static void main(String[] args) { Scanner in = new Scanner(System.in); //input for currentState 57:52 int currentState_size = in.nextInt(); int currentState[] = new int [current State_size]; for(int idx = 0; idx < currentState_size; idx++) { currentState [idx] = in.nextInt (); } // input for days int days = in.nextInt (); int [1 recult - streetlight(current state davel. ^ 123 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 22 import java.util.*; import java.lang.*; import java.io.*; /* * */ public class Solution { public static int [] streetLight (int[] current State, int days) { } int[] answer = new int [100]; // Write your code here I return answer; public static void main(String[] args) { Scanner in = new Scanner(System.in); //input for currentState 57:52 int currentState_size = in.nextInt(); int currentState[] = new int [current State_size]; for(int idx = 0; idx < currentState_size; idx++) { currentState [idx] = in.nextInt (); } // input for days int days = in.nextInt (); int [1 recult - streetlight(current state davel. ^
Expert Answer:
Answer rating: 100% (QA)
It looks like youve been given a task to complete a Java program that simulates the behavior of street lights under a specific set of rules for a give... View the full answer
Related Book For
Accounting Information Systems
ISBN: 978-1133935940
10th edition
Authors: Ulric J. Gelinas, Richard B. Dull
Posted Date:
Students also viewed these programming questions
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A rectangular loop of wire with sides 0.20 and 0.35 m lies in a plane perpendicular to a constant magnetic field (see part a of the drawing). The magnetic field has a magnitude of 0.65 T and is...
-
Shan Enterprises received a bank statement listing its May 31, 2016, bank balance as $47,582. Shan determined that as of May 31 it had cash receipts of $2,500 that were not yet deposited and checks...
-
A company that currently produces final product A is considering stopping processing earlier in the production process and selling the intermediate product on the market. The final product sells for...
-
Posting a $800 purchase of supplies on account appears as which of the following? a. Supplies 800 Accounts Receivable 800 C. Supplies 800 Accounts Payable 800 b. Supplies Accounts Payable d. Cash...
-
1. Document the effects of the GAAP differences in the 20F by doing the following: a. For the current year, calculate the percentage change for net income and for total shareholders equity indicated...
-
determining whether a firm financial position is improving or deteriorating requires analysis of more than one set of financial statements
-
1. Using the information in the table, compute the structure of the optimal portfolio W when there are two risky assets, bond fund and stock fund, as well as one risk free asset. r=0.03. Please note...
-
Wimpy earns $200 per month and consumes 60 Hardees hamburgers each month. He pays $2 for each hamburger. Hardees is considering implementing a frequent-eaters program whereby a monthly charge of $30...
-
Show that 3 is irrational.
-
Alta Company is constructing a production complex that qualifies for interest capitalization. The following information is available: Capitalization period: January 1, 2019, to June 30, 2020...
-
Colt McCoy Co. started had the following transactions related to inventory in December Beginning inventory December 5 Purchase December 7 Sold December 20 Purchase December 25 Sold December 26...
-
There is a square field ABCD near my house. My dog Fido is tethered to a pole so that the distance from the pole to A is 17 feet, to B is 24 feet, and to C is 25 feet. Find the area of the square...
-
Based on the cost data below, this firm has total fixed costs equal to: Output Total Variable Cost Total Cost 0 $0 $45 1 $40 $_ 23 $70 $115 $90 $ Select an answer and submit. For keyboard navigation,...
-
AABC is equilateral. XY is parallel to AC, and Z is on AC produced so that BY = CZ. Prove that XC is parallel to YZ. B Y A C N
-
What tools are available to help shoppers compare prices, features, and values and check other shoppers opinions?
-
Discuss how you determine the placement of primary keys in relational tables to link the tables to each other.
-
Provide an example of a business event. Explain how an enterprise system can provide the ability to share information and make the execution of the event efficient.
-
Use the Internet to locate www.cia.gov and www.Amazon.com. Find the privacy and security policies for each. Compare and contrast the use of privacy statements, encryption, SSL, and cookie policies.
-
Suppose the US investor in Question 8 were risk averse, instead of risk neutral, and wants a risk premium of \(1 \%\) (annual) for assuming the exchange-rate risk on the international investment. a....
-
When there is a concentration gradient in the system, show that the potential gradient is composed of two terms, (i) an Ohm's-law contribution and (ii) a diffusional contribution. State the equation...
-
Copper is deposited at a cathode from solution with a bulk concentration of \(0.5 \mathrm{M}\) at the rate of \(3.0 \mathrm{~g} / \mathrm{m}^{2} \cdot \mathrm{s}\). Find the surface concentration of...
Study smarter with the SolutionInn App