Question

In: Computer Science

Write a program which shows how two-dimensional arrays which contain multiple copies of your id number...

Write a program which shows how two-dimensional arrays which contain multiple copies of your id number and age are passed to methods. Explain in your own words each method and class used in the program.

My id number is 12133149

Solutions

Expert Solution

Thanks for the question.

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please rate the answer. Thanks!
===========================================================================

public class TwoDArray {


    public static void main(String[] args) {

        // creat a 2D array with 3 rows and 2 columns
        // column 1 (index 0) will be store my id : 12133149
        // column 2 (index 1) will be store my age : 20
        int myData[][] = new int[3][2];

        // fill the 2d array with my id and age
        myData[0][0] = 12133149; myData[0][1] = 20;
        myData[1][0] = 12133149; myData[1][1] = 20;
        myData[2][0] = 12133149; myData[2][1] = 20;

        // will pass the 2D array to print2DArray mehtod which will display the 2D array
        print2DArray(myData);
    }

    private static void print2DArray(int[][] myData) {

        // fetch how many rows the 2D array contains
        for (int row = 0; row < myData.length; row++) {

            System.out.println("Row #" + (row + 1));

            //fetch how many columns each row contains
            for (int col = 0; col < myData[row].length; col++) {
                // display the values

                System.out.println("Col #" + (col + 1) + ", Value: " + myData[row][col]);

            }

        }
    }
}

====================================================================


Related Solutions

Write a program which shows how two-dimensional arrays which contain multiple copies of your id number...
Write a program which shows how two-dimensional arrays which contain multiple copies of your id number and age are passed to methods. Explain in your own words each method and class used in the program.
Write C program Multidimensional Arrays Design a program which uses two two-dimensional arrays as follows: an...
Write C program Multidimensional Arrays Design a program which uses two two-dimensional arrays as follows: an array which can store up to 50 student names where a name is up to 25 characters long an array which can store marks for 5 courses for up to 50 students The program should first obtain student names and their corresponding marks for a requested number of students from the user. Please note that the program should reject any number of students that...
Multidimensional Arrays Design a C program which uses two two-dimensional arrays as follows: - an array...
Multidimensional Arrays Design a C program which uses two two-dimensional arrays as follows: - an array which can store up to 50 student names where a name is up to 25 characters long - an array which can store marks for 5 courses for up to 50 students The program should first obtain student names and their corresponding marks for a requested number of students from the user. Please note that the program should reject any number of students that...
Multidimensional Arrays Design a C program which uses two two-dimensional arrays as follows: - an array...
Multidimensional Arrays Design a C program which uses two two-dimensional arrays as follows: - an array which can store up to 50 student names where a name is up to 25 characters long - an array which can store marks for 5 courses for up to 50 students The program should first obtain student names and their corresponding marks for a requested number of students from the user. Please note that the program should reject any number of students that...
[C++ Coding question] write a program which inputs data to a two-dimensional array: - Input number...
[C++ Coding question] write a program which inputs data to a two-dimensional array: - Input number of rows r aand number of columns c - Create a two-dimensional array of integers int numbers[r][c] -input data for each element of numbers Your program must compute and display the largest number is each row and column of the number array
Write a program that copies the even number of bits from a into the corresponding bits...
Write a program that copies the even number of bits from a into the corresponding bits in b ,only use bit-manipulation instructions, no loop int main () { uint_32 a = 0 xaabbccdd ; uint_32 b = 0 x11223344 ; // Replace bits 0 ,2 ,4 ,... of b with bits 0 ,2 ,4 ,... from a . uint_32 result = ...; // Print out the result as a hexadecimal number }
Write a program that contains the following Write a function copies with two int parameters, named...
Write a program that contains the following Write a function copies with two int parameters, named n and x. It should dynamically allocate a new array of size n.  The function should then copy the value in x to every position in the array. The function should return a pointer to the new array. In the main function, call the copies function from part 1. with size 5 and value -1.  Output the resulting array to the screen, and deallocate the array....
This is for c++ Write a program that works with two arrays of the same size...
This is for c++ Write a program that works with two arrays of the same size that are related to each other in some way (or parallel arrays). Your two arrays must be of different data types. For example, one array can hold values that are used in a formula that produces the contents of the second array. Some examples might be:  from a previous program, populations and the associated flowrates for those populations (an int array of populations...
Write a program in java which has two arrays of size 4 and 5; merge them...
Write a program in java which has two arrays of size 4 and 5; merge them and sort.
Write a program that concatenates the characters in a two-dimensional into a set of Strings in...
Write a program that concatenates the characters in a two-dimensional into a set of Strings in a one-dimensional array as described below. main #Request and Read in the number of rows of a two dimensional array. #Create the reference to the two-dimensional array. For each row #Request and Reads in a line of text #Based on the length of the line create a row with the correct number of columns (look #back to lesson 3) #Place each character for the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT