Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
IT LEARNING 2D Array Revision Hasan Ali Hasan Ali 33019949 import java.util.Scanner; public class ITLearning { public static void main(String[]args){ Scanner kbd = new Scanner (System.in); int [][] array = new int[5][4]; for(int row=0 ; row< array.length ; row++){ System.out.println("Enter 5 numbers for row "+row); for(int col=0 ; col< array[row].length ; col++) array[row][col]=kbd.nextInt(); } System.out.println("The sum equals 100 in row: "); for(int row=0 ; row< array.length ; row++){ int sum=0; for(int col=0 ; col< array[row].length;col++) sum+=array[row][col]; if(sum==100) System.out.println(row); } } } Hasan Ali 33019949 import java.util.Scanner; public class ITLearning { public static void main(String[]args){ Scanner kbd = new Scanner (System.in); int row , col; System.out.println("Enter number of rows and columns: "); row= kbd.nextInt(); col= kbd.nextInt(); int [][] array=new int[row][col]; for(int i=0 ; i< array.length ; i++){ System.out.println("Enter elements for row "+i); for(int k=0 ; k< array[i].length;k++) array[i][k]=kbd.nextInt(); } int sum1 =0; for(int k=0 ; k<col ; k++) sum1+=array[0][k]; boolean magic=true; for(int i=1 ; i< array.length ; i++){ int sum2=0; for(int k=0 ; k< array[i].length ; k++) sum2+=array[i][k]; if(sum1!=sum2){ magic=false; break; Hasan Ali 33019949 } } if(magic==false) System.out.print("The array is not Row-Magic"); else System.out.print("The array is RowMagic"); } } Hasan Ali 33019949 import java.util.Scanner; public class ITLearning { public static void main(String[]args){ Scanner kbd = new Scanner (System.in); int [][] matrix = new int[3][4]; System.out.println("Enter Matrix:"); for(int row=0 ; row< matrix.length ; row++){ for(int col=0 ; col< matrix[row].length ; col++) matrix[row][col]=kbd.nextInt(); } int[][] matrixT = new int[4][3]; for(int i=0 ; i<4 ; i++){ for(int k=0 ; k<3 ; k++) matrixT[i][k]=matrix[k][i]; } System.out.println("Transpose of the Matrix is:"); for(int i=0 ; i<4 ; i++){ for(int k=0 ; k<3 ; k++) System.out.print(matrixT[i][k]+" "); Hasan Ali 33019949 System.out.println(" "); } } } Hasan Ali 33019949 import java.util.Scanner; public class ITLearning { public static void main(String[]args){ Scanner kbd = new Scanner (System.in); //1int n; System.out.print("Enter number of students: "); n=kbd.nextInt(); double [][] marks= new double[n][5]; //2for(int i=0 ; i<n ;i++){ System.out.println("Enter the marks for student "+i); for(int k=0 ; k<5 ; k++) marks[i][k]= kbd.nextDouble(); Hasan Ali 33019949 } //3double [][] rmarks= new double[n][5]; for(int i=0; i<n ;i++){ int col=4; for(int k=0 ; k<5 ; k++) rmarks[i][k]=marks[i][col--]; } //4for(int i=0 ; i<n ; i++){ if(marks[i][2]>=5.0) marks[i][2]+=2; } //5System.out.println("Marks Array:"); for(int i=0 ; i<n ; i++){ for (int k=0 ; k<5 ; k++) System.out.print(marks[i][k]+" "); System.out.println(" "); } System.out.println("rMarks Array:"); for(int i=0 ; i<n ; i++){ for (int k=0 ; k<5 ; k++) System.out.print(rmarks[i][k]+" "); System.out.println(" "); } } } Hasan Ali 33019949