Page 326 - computer science (868) class 11
P. 326

13.  Write a program in Java to store the names of the 10 politicians and their parties to which they belong to in two separate arrays.
                    Ask the users to enter the name of the party. Print out all the names of the politicians who belong to that party. Repeat the
                    process according to user choice.
                 14.  Write a Java program to generate 10 terms of the Fibonacci series in a single-dimensional array.
                 15.  Write a Java program to input 10 different numbers and arrange them in such a way that all the even numbers are arranged in
                    ascending order followed by all odd numbers.
                 16.  Create a square matrix of size M × M and check whether it is a symmetric matrix or not. A symmetric matrix is a square matrix
                    that is equal to its transpose.
                 17.  Write a program in Java to generate a Pascal triangle in which each number in the row is the sum of the two numbers immediately
                    above it. The program should print the first six rows of the triangle.
                     (Hint: E[J.I]  =  P[I-1,J-1] + P[I-1,J] is true for all elements but the boundary elements which are all equal to 1)
                 18.  Write a program in Java to input elements in a 3x3 matrix and swap the numbers of the 1st row with the 3rd row of a given matrix.
                 19.  Write a program in Java to create a 3x3 matrix and print the highest value of each column in the following manner.

                      5   7    4
                      4   6    2
                      8   2   10
                     Highest value in column 1 = 8
                     Highest value in column 2 = 7
                     Highest value in column 3 = 10
                 20.  Write a Java program to declare a square matrix M [ ] [ ] of order ‘N’ where ‘N’ must be greater than 3 and less than 10. Allow the
                    user to accept three different characters from the keyboard and fill the array according to the instructions given below:
                     (i)   Fill the four corners of the square matrix by character 1.
                     (ii)   Fill the boundary elements of the matrix (except the four corners) by character 2.
                     (iii)  Fill the non-boundary elements of the matrix by character 3.
                     Test your program with the following data and some random data:
                     INPUT: N = 4
                     FIRST CHARACTER   :    @
                     SECOND CHARACTER  :    ?
                     THIRD CHARACTER   :    #
                     OUTPUT:
                     @    ?    ?    @
                     ?    #    #     ?
                     ?    #    #    ?
                     @    ?    ?    @
                 21.  Write a program in Java to input and store n integers (n > 0) in a single subscripted variable and print each number with its
                    frequency. The output should contain the number and its frequency in two different columns.
                     Sample Input:   12  20  4  12  12  20  16   16  14   14  12   20  18   18
                     Sample Output:
                     Number      Frequency
                     12             4
                     14             3
                     16             2
                     18             2
                     20             3
                 22.  Write a program in Java to input elements in a 2D square matrix and check whether it is a Lower Triangular Matrix or not.
                     Lower Triangular Matrix: A Lower Triangular matrix is a square matrix in which all the entries above the main diagonal are zero.
                    The entries below or on the main diagonal must be non-zero values.
                     For example:
                     Enter the size of the matrix: 4
                     The Matrix is:
                     5 0 0 0
                     3 1 0 0
                     4 9 4 0
                     6 8 7 2
                     The Matrix is Lower Triangular

                324324  Touchpad Computer Science-XI
   321   322   323   324   325   326   327   328   329   330   331