Write Code Segments that Require Two-Dimensional Arrays
Need Help? Check out these resources!
Your Turn
- Write program code to complete the provided tasks.
- Run the code in the Java Playground to see if your code generates the desired result.
- Make necessary changes until you have satisfied the tasks.
Practice 1: Temperatures Array
- Write a code segment that initializes a 7x24
doublearray for storing hourly temperatures over a week and sets all values to 0.0 as a default. - Try the code in the Java Playground to verify your prediction.
Practice 2: Alternating True and False
- Create a
boolean[][] boardthat is a 5x5 two-dimensional array. The values should alternate betweentrueandfalse. Even rows will start withtrueand odd rows will start withfalse. - Try the code in the Java Playground to verify your prediction.