Advertisement
ruhul0

Array-assignmnet

Feb 25th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Array {
  4.     private int row, column;
  5.     public int getColumn() {
  6.         return column;
  7.     }
  8.  
  9.     public void setColumn(int column) {
  10.         this.column = column;
  11.     }
  12.  
  13.     public int getRow() {
  14.         return row;
  15.     }
  16.  
  17.     public void setRow(int row) {
  18.         this.row = row;
  19.     }
  20.     private int[][] matrix = new int [row] [column];
  21.     public int[][] getMatrix() {
  22.         return matrix;
  23.     }
  24.  
  25.     public void setMatrix(int[][] matrix) {
  26.         this.matrix = matrix;
  27.     }
  28.     void inputMatrix()
  29.     {
  30.         Scanner sc = new Scanner (System.in);
  31.         for(int i = 0; i<row;i++)
  32.         {
  33.             for(int j=0;j<column;j++)
  34.             {
  35.                 matrix[i][j] = sc.nextInt();
  36.             }
  37.         }
  38.     }
  39.     void outputMatrix()
  40.     {
  41.         for(int i=0; i <row ; i++)
  42.         {
  43.             for(int j=0; j<column;j++)
  44.             {
  45.                 System.out.print(matrix[i][j]);
  46.             }
  47.         }
  48.        
  49.     }
  50.     void maxElement()
  51.     {
  52.         int max = 0;
  53.         for(int i=0; i<row;i++)
  54.         {
  55.             for(int j=0; j<column; j++)
  56.             {
  57.                 if(max<matrix[i][j])
  58.                 {
  59.                     max = matrix[i][j];
  60.                 }
  61.             }
  62.         }
  63.         System.out.println("Maximum is: " + max);
  64.     }
  65.  
  66.    
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement