Run the code. When Arrays2D.java runs as expected, make the following changes: 1.1. Change the value of the second row of the array to { 15, 16, 17, 18 }. 1.2. Print the values for each row on the same line. Program output should look like: 123 4 15 16 17 18- 8 10 12 14e 1.3. Add the following line at the end of the program: System.out.printIn( "The value of the first element onl the first row is" + pumbers[olro): This output should only appear once in a program run e

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
100%

Please answer the question posted and give full explanation to the answer.

Please remember to put your name and date of program completion in a comment at the top of
your .java file.
Create a Java project with the following code. Please remember to type in this code rather than copy-
and-pasting; Word loves to mangle source code.
Arrays2D.java:
// Student Name Today's Date
/**
* This program shows values being stored in an array's elements and displayed.
* From Gaddis Starting Out with Java, 6th Edition
*/e
public class Arrays2D {+
public static void main(String[] args) {"
int[][] numbers = { { 1, 2, 3, 4 }, «
{ 5, 6, 7, 8 }, +
{ 8, 10, 12, 14 } };-
for (int row = 0; row < numbers.length; row++) {-
for (int col = 0; col < numbers[row].length; col++) {-
System.out println(numbers[row][col]);-
}
Run the code. When Arrays2D.java runs as expected, make the following changes:
1.1. Change the value of the second row of the array to { 15, 16, 17, 18 }.
1.2. Print the values for each row on the same line.
Program output should look like:
123 44
15 16 17 18
8 10 12 14-
1.3. Add the following line at the end of the program: System.out.println( "The value of the first element
on the first row is" + numbers[0][0]); . This output should only appear once in a program run.
Transcribed Image Text:Please remember to put your name and date of program completion in a comment at the top of your .java file. Create a Java project with the following code. Please remember to type in this code rather than copy- and-pasting; Word loves to mangle source code. Arrays2D.java: // Student Name Today's Date /** * This program shows values being stored in an array's elements and displayed. * From Gaddis Starting Out with Java, 6th Edition */e public class Arrays2D {+ public static void main(String[] args) {" int[][] numbers = { { 1, 2, 3, 4 }, « { 5, 6, 7, 8 }, + { 8, 10, 12, 14 } };- for (int row = 0; row < numbers.length; row++) {- for (int col = 0; col < numbers[row].length; col++) {- System.out println(numbers[row][col]);- } Run the code. When Arrays2D.java runs as expected, make the following changes: 1.1. Change the value of the second row of the array to { 15, 16, 17, 18 }. 1.2. Print the values for each row on the same line. Program output should look like: 123 44 15 16 17 18 8 10 12 14- 1.3. Add the following line at the end of the program: System.out.println( "The value of the first element on the first row is" + numbers[0][0]); . This output should only appear once in a program run.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 6 images

Blurred answer
Knowledge Booster
SQL Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT