Question

1.The code box below includes a live 2 dimensional array variable called gridNums. This array holds...

1.The code box below includes a live 2 dimensional array variable called gridNums. This array holds integers. You cannot see its declaration or initialization.
What value is in the zeroth (initial) position of the second row? Print this array entry to the console. (Note: remember that the second row is actually row 1). Enter your code in the box below.

2.The code box below includes a live 3x3 2-dimensional array variable called fredsNums. This array holds integers. You cannot see its declaration or initialization. What value is in the southwest corner of the array? Write a statement (or statements) that prints this value to the console.

3.The code box below contains a live 2D array of integers called someInts. This array has a rectangular shape. Write one or several lines of code that determines and then prints to the console the number of columns in the array.

4.The code box below contains a live 2D rectangular array of characters (char) called someChars. Write a looping statement that allows you to calculate, and then print to the console, the number of entries in the array that are (lower case) 'x'.

For example, if the array looks like this:

x o o x y
y y x p q


then your code should print 3 to the console.

The answer you enter should execute exactly one System.out.println statement.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
1. System.out.println(gridNums[1][0]);
2. System.out.println(fredsNums[2][2]);
3. System.out.println(someInts[0].length);
4.
int count = 0;
for(char[] row: someChars) {
        for(char c: row) {
                if(c == 'x') {
                        count++;
                }
        }
}
System.out.println(count);
Add a comment
Know the answer?
Add Answer to:
1.The code box below includes a live 2 dimensional array variable called gridNums. This array holds...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The code box below contains a live 2D rectangular array of characters (char) called someChars. Write...

    The code box below contains a live 2D rectangular array of characters (char) called someChars. Write a looping statement that allows you to calculate, and then print to the console, the number of entries in the array that are (lower case) 'x'. For example, if the array looks like this: x o o x y y y x p q The answer you enter should execute exactly one System.out.println statement. In Java please.

  • Here is the code for the Infant class: public class Infant{ private String name; private int...

    Here is the code for the Infant class: public class Infant{ private String name; private int age; // in months public Infant(String who, int months){ name = who; age = months; } public String getName(){ return name;} public int getAge(){ return age;} public void anotherMonth() {age = age + 1;} } The code box below includes a live Infant array variable, thoseKids. You cannot see its declaration or initialization. Your job is to find out which Infant in the array...

  • in java / You will: // 1- create a square 2 dimensional array of random size...

    in java / You will: // 1- create a square 2 dimensional array of random size (less than 11) // 2- fill the array with random integers from 1 to the size limit // 3- print the array // 4- prompt to see if the user wants to do another //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 1- The square can use the same random value for x and y. Don't allow 0 size arrays. // 2- Maybe a nested set of for loops? to...

  • Use C Programming DESCRIPTION Write a program that: Creates a Dimensional, integer array that holds 8...

    Use C Programming DESCRIPTION Write a program that: Creates a Dimensional, integer array that holds 8 values Prompts the user to enter 8 integers between 0 and 20 [inclusive) and stores the data in the array Prints the data in array abng with a histogram of the data as shown below. There is no requirement to validate the data. You must use a constant to declare your array and control any loops you need Sample Output: Enter 8 integer values...

  • Imagine we are using a two-dimensional array as the basis for creating the game battleship. In...

    Imagine we are using a two-dimensional array as the basis for creating the game battleship. In the game of battleship a '~' character entry in the array represents ocean, a '#' character represents a place ion the ocean where part of a ship is present, and an 'H' character represents a place in the ocean where part of a ship is present and has been hit by a torpedo. Thus, a ship with all 'H' characters means the ship has...

  • C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand h...

    C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand how to traverse a two dimensional array Code and run a program that processes a two dimensional array Instructions: A magic square is a matrix (two dimensional arrays) in which the sum of each row, sum of each column, sum of the main diagonal, and sum of the reverse diagonal are all the same value. You are to code a program to determine...

  • need question 3 assap using cin and cout outputs please Ctrl CSC 270 Final Exam-Spring2 1) [10 pts] Create anarray x which includes integers fron ltos obtain the array y which, even formula. Displ...

    need question 3 assap using cin and cout outputs please Ctrl CSC 270 Final Exam-Spring2 1) [10 pts] Create anarray x which includes integers fron ltos obtain the array y which, even formula. Display both arrays x and y in a table with labeled column headings. 0 y- 2x+1 2) 120 pts] Consider the following 2D array. 01 2 -1 X-3 5 0 6 -3 7 -15 Use the standard notation and obtain the following (a) Create and display array...

  • . Q7. Write a C++ class called Point2D that describes a 2-dimensional (x,y) point. It should...

    . Q7. Write a C++ class called Point2D that describes a 2-dimensional (x,y) point. It should have the following features: • A constructor that accepts two double values (x,y) to create a point object. A default constructor. • A void print() method that prints out the points coordinates. • A void set(Point2D p) method that allows you to set the point using the given object of Point2D. • A Point2D midPoint(Point2D p1) method that returns a Point2D object that is...

  • Write the following Java code for a file called input.txt that has the below text in...

    Write the following Java code for a file called input.txt that has the below text in it. 5 6 1 1 0 0 1 1 0 1 0 0 1 1 0 1 0 0 2 1 0 3 1 1 1 1 1 2 3 4 5 1 2 0 1 hello 2 3 bye Create the Entry class. · Entry should have 3 data members o int x. o int y. o String name. Create a class called...

  • Write a Java program with a single-dimension array that holds 11 integer numbers and sort the...

    Write a Java program with a single-dimension array that holds 11 integer numbers and sort the array using a bubble sort. Next, identify the median value of the 11 integers. Here are the steps your program must accomplish. algorithm (either flowchart or pseudocode) that you will use to write the program Step 1. Create an Place the algorithm in a Word document. 6. Ste the Step 2. Code the program in Eclipse and ensure the following steps are accomplished. 1....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT