subject

Write a method public static void printRuns (int [] [] values, int runLength) that takes a 2D array of integers and prints out which rows and columns (and/or parts of rows and columns) contain runs of length runLength. A run is a group of identical consecutive values. For example 7, 7, 7is a run of length 3. Each print-out must clearly indicate which part of a row or column contains the run. The example method call outputs given below will help to clarify what the method does and what its output should be. In the output, assume that the row and column numbering begins at 0, not 1. You may assume that the values array is rectangular (i. e., not ragged) For the examples below, suppose we have the following 2D array: int [] [ = new int [] [] { nums2D 5, 5, 0, 5, 2}, 1, 2, 2, 2, 2}, 2, 4, 2, 2, 2}, 2, 2, 2, 2, 2}, 3, 3, 2, 2, 2}, {4, 4, 2, 2, 0}, 4, 2, 2, 2, 8}};
Method call: printRuns (nums2D, 4);
Expected output:
Row 1, columns 1 - 4
Row 3, columns 0 - 3
Row 3, columns 1 - 4
Column 2, rows 1 4
Column 2,
Column 2, 5 rows 2 rows 3
Column 3, rows 1
Column 3, 5 rows 2
Column 3, rows 3 - 6
Column 4, 3 rows 0
Column 4 rows 1- 4
Method call: printRuns (nums2D, 5)
Expected output:
Row 3, columns 0
Column 2, 5 rows 1
Column 2, 6 rows 2
Column 3, 5 rows 1
Column 3, rows 2
Column 4, rows 0- 4
Method call: printRuns (nums2D, 6); Ln 4Ln LO LO
Expected output:
Column 2, rows 1 - 6
Column 3, rows 1 - 6
Method call: printRuns (nums 2D, 7);
Expected output:
(no output

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
The “rule of 72” is used to approximate the time required for prices to double due to inflation. if the inflation rate is r%, then the rule of 72 estimates that prices will double in 72/r years. for instance, at an inflation rate of 6%, prices double in about 72/6 or 12 years. write a program to test the accuracy of this rule. for each interest rate from 1% to 20%, the program should display the rounded value of 72/r and the actual number of years required for prices to double at an r% inflation rate. (assume prices increase at the end of each year.)
Answers: 1
question
Computers and Technology, 23.06.2019 05:00
In cell b18, enter a formula to calculate the amount budgeted for meals. this amount is based on the daily meal allowance and the total travel days (# of nights+1).
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Write a program that displays the following menu: geometry calculator 1. calculate the area of a circle 2. calculate the area of a rectangle 3. calculate the area of a triangle 4. quit enter your choice (1-4): if the user enters 1, the program should ask for the radius of the circle and then display its area. use the following formula: area = ď€(the square of r) use 3.14159 for ď€ and the radius of the circle for r. if the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. use the following formula: area = length * width if the user enters 3, the program should ask for the length of the triangle’s base and its height, and then display its area. use the following formula: area = base * height * .5 if the user enters 4, the program should end. input validation: display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height. note: if the user enters an improper menu choice (1-4), the program prints "the valid choices are 1 through 4. run the program again and select one of those." if the user enters a negative radius, the program prints "the radius can not be less than zero." if the user enters a negative value for height or base, the program prints "only enter positive values for base and height."
Answers: 1
question
Computers and Technology, 25.06.2019 08:50
1. define independent-set as the problem that takes a graph g and an integer k and asks whether g contains an independent set of vertices of size k. that is, g contains a set i of vertices of size k such that, for any v and w in i, there is no edge (v,w) in g. show that independent-set is np-complete.
Answers: 3
You know the right answer?
Write a method public static void printRuns (int [] [] values, int runLength) that takes a 2D array...
Questions
question
Mathematics, 10.03.2021 01:00
question
Mathematics, 10.03.2021 01:00
question
Mathematics, 10.03.2021 01:00
Questions on the website: 13722363