Status: Not Started
  • Data.java
  • DataTester.java
Font Size
14
Parentheses autocomplete
Wrap lines
Editor
Theme
Code with blocks by default
Console Font Size
12
Console Theme
Display Server Graphics Screen
Show File Tab Bar
Debug Mode
5 Data Part a (run code)
DataTester.java
public class DataTester
{
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Output
Grading
Docs
Exercise
More
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Pass Test Message

Errors:

This student is viewing this assignment in English. View this page in English?

5 points

This question involves a two-dimensional array of integers that represents a collection of randomly generated data. A partial declaration of the Data class is shown. You will write two methods of the Data class.


public class Data

{

public static final int MAX = /* value not shown */;

private int[][] grid;


/** Fills all elements of grid with randomly

* generated values, as described in part (a)

* Precondition: grid is not null.

* grid has at least one element.

*/

public void repopulate()

{ /* to be implemented in part (a) */ }


/** Returns the number of columns in grid that are in

* increasing order, as described in part (b)

* Precondition: grid is not null.

* grid has at least one element.

*/

public int countIncreasingCols()

{ /* to be implemented in part (b) */ }


// There may be instance variables, constructors, and methods that are not shown.

}


Part a

Write the repopulate method, which assigns a newly generated random value to each element of grid. Each value is computed to meet all of the following criteria, and all valid values must have an equal chance of being generated.


  1. The value is between 1 and MAX, inclusive.
  2. The value is divisible by 10.
  3. The value is not divisible by 100.


Complete the repopulate method.

Reset Code

Slides and Notes

No slides available for this video

About

Java (main)
Java Version 1.8.0_222