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 }
The two-dimensional arrays list1 and list2 are identical if they have the same contents. Write a...
The two-dimensional arrays list1 and list2 are identical if they have the same contents. Write a method that returns true if they are identical and false if they are not. Use the following header: public static boolean equals(int [][] list1, int [][] list2) Write a test program that prompts the user to enter two 3 x 3 arrays of integers and displays whether the two are identical. Enter list1: Enter list2: The two arrays are identical or The two arrays...
>>>>>C#<<<<< A.     Number Frequency-Arrays Write a program to count the number of 10’s in the given...
>>>>>C#<<<<< A.     Number Frequency-Arrays Write a program to count the number of 10’s in the given list of 15 numbers. The output should look like:                                                                                                        [01] Extend your program to work with a list of n numbers.                                         [01]                                                                                              Random Numbers-Methods Write a program to generate a 10 Random Numbers:                                           [01] Extend your program to generate n Random numbers.                                         [01] B.    Word Count -String Processing Write a program to count the occurrence...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT