Java Bootcamp – Workbooks and Challenges
)}

Workbook 6.14

From Java Bootcamp Resources -> Module 1 -> 6. Arrays, open Workbook 6.14.

Random Numbers!

In this workbook, you'll generate a thousand random numbers and store them in a 2D array.

Task 1


Write a function that returns a random number between 1 and 100.

/** * Function name: randomNumber. * * @return randomNumber (int) * * Inside the function: * 1. return a random number between 1 and 100. */

Task 2


Write a function that prints any 2D array in this format.

  • Each row takes up one line.

  • There's a space between each value in the row.

Hint: use a nested loop.

/** * Function name: print2DArray * @param array ( int[][] ) * * Inside the function: * 1. print the array such that: * - Each row takes up one line. * - There's a space between each value. */

Task 3


Create a 2D array with 100 rows and 10 columns. Then, call print2DArray.

Task 4


Using a nested loop, populate the array with random numbers before calling: print2DArray.

Good Luck!

Feedback Summary
4.8
39 students
5

92%
4

3%
3

0%
2

0%
1

5%
Written Reviews
There are no written reviews yet.