subject

Consider the following class. public class LightSequence { // attributes not shown /** The parameter seq is the initial sequence used for * the light display */ public LightSequence(String seq) { /* implementation not shown */ } /** Inserts the string segment in the current sequence, * starting at the index ind. Returns the new sequence. */ public String insertSegment(String segment, int ind) { /* implementation not shown */ } /** Updates the sequence to the value in seq */ public void changeSequence(String seq) { /* implementation not shown */ } /** Uses the current sequence to turn the light on and off * for the show */ public void display() { /* implementation not shown */ } } Question 1 (a) Write a statement to create a LightSequence object gradShow that has the initial light sequence "0101 0101 0101". Write the statement below. Question 2 (b) Write a statement that will call the display method to display the light sequence for the gradShow object. Write the statement below. Question 3 (c) Write a statement that will be used to update the gradShow light sequence to "0011 0011 0011". Write the statement below. Question 4 (d) Write a code segment that will call the insertSegment method to insert the segment "1111 1111" in the current sequence for gradShow at index 4. The resulting sequence will be stored in the string resultSeq. Write the code segment below. Question 5 (e) Assume that the string oldSeq has been properly declared and initialized. Write a code segment that will remove the first occurrence of the string segment from oldSeq and store it the string newSeq. Consider the following examples. If oldSeq is "1100000111" and segment is "11", then "00000111" should be stored in newSeq. If oldSeq is "0000011" and segment is "11", then "00000" should be stored in newSeq. If oldSeq is "1100000111" and segment is "00", then "11000111" should be stored in newSeq. If oldSeq is "11111" and segment is "00", then "11111" should be stored in newSeq. Write the code segment below. Your code segment should meet all specifications and conform to the examples. Question 6 (f) Two lights will be arranged on a two-dimensional plane. The vertical distance between the two lights is stored in the double variable a. The horizontal distance between the two lights is stored in the double variable b. The straight-line distance between the two lights is given by the formula a2+b2βˆ’βˆ’βˆ’βˆ’βˆ’βˆ’βˆš. Write a code segment that prints the straight-line distance between the two lights according to the formula above.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 23.06.2019 22:20
Read β€œsuburban homes construction project” at the end of chapters 8 and 9 (in the textbook) and then develop a wbs (work breakdown structure) in microsoft excel or in microsoft word (using tables)
Answers: 1
question
Computers and Technology, 24.06.2019 07:30
Aproject involves many computing systems working together on disjointed task towards a single goal what form of computing would the project be using
Answers: 3
question
Computers and Technology, 24.06.2019 12:40
Match the feature to the network architecture. expensive to set up useful for a small organization easy to track files has a central server inexpensive to set up difficult to track files useful for a large organization does not have a central server client- server network peer-to-peer network
Answers: 3
You know the right answer?
Consider the following class. public class LightSequence { // attributes not shown /** The parameter...
Questions
question
Mathematics, 15.12.2020 22:50
question
Mathematics, 15.12.2020 22:50
Questions on the website: 13722363