PROGRAM TO FIND THE VOLUME OF A BOX USING OBJECTS
//PROGRAM TO FIND THE VOLUME OF A BOX USING OBJECTS class Box { int l,b,h; int volume( ) { return(l*b*h); } } class Abc { public static void main(String args[ …
//PROGRAM TO FIND THE VOLUME OF A BOX USING OBJECTS class Box { int l,b,h; int volume( ) { return(l*b*h); } } class Abc { public static void main(String args[ …
//SORT THE LIST IN ASCENDING ORDER USING BUBBLE SORT – JAVA class Bubblesort { public static void main(String args[ ]) { int a[ ]={7,3,9,1,2,43,23,10}; int i,j,l,temp; l=a.length; System.out.println(“Elements in the …
//PROGRAM TO FIND THE TRANSPOSE OF MATRIX class Transpose { int a[ ][ ]={{1,2,3},{3,5,6}}; int b[ ][ ]={{0,0},{0,0},{0,0}}; int i,j; void calculate( ) { for(i=0;i<2;i++) { for(j=0;j<3;j++) { b[j][i]=a[i][j]; } …
//PROGRAM TO PERFORM MULTIPLICATION OF TWO MATRICES class Multiplication { int[ ][ ] a={{1,2,3,4},{2,3,4,5}}; int[ ][ ] b={{1,1},{4,5},{3,4},{2,8}}; int[ ][ ] c={{0,0},{0,0}}; int i,j,k; void calculate( ) { for(i=0;i<2;i++) { …
//PROGRAM TO PERFORM SUBTRACTION OF TWO MATRICES class SubMatrix { int a[ ][ ]={{1,2,3,4},{4,5,6,7}}; int b[ ][ ]={{0,4,7,2},{6,1,8,3}}; int c[ ][ ]={{0,0,0,0},{0,0,0,0}},i,j; void subtract( ) { for(i=0;i<2;i++) { for(j=0;j<4;j++) { …
//PROGRAM TO PERFORM ADDITION OF TWO MATRICES class addmatrix { int a[ ][ ]={{1,2,3,4},{4,5,6,7}}; int b[ ][ ]={{0,4,7,2},{6,1,8,3}}; int c[ ][ ]={{0,0,0,0},{0,0,0,0}},i,j; void add( ) { for(i=0;i<2;i++) { for(j=0;j<4;j++) { …
//PROGRAM TO CALCULATE FACTORIAL OF A NUMBER class Factorial { public static void main(String args[ ]) { int i,s=1; System.out.println(“Printing the factorial of 5: “); for(i=5;i>=1;i–) { s=s*i; } System.out.println(“Factorial …
//PROGRAM TO FIND MINMUM AND MAXIMUM ELEMENT IN AN ARRAY class minMax { public static void main(String args[ ]) { int a[ ]={2,43,1,5,9,5,22,11,10}; int min,max,i,j; System.out.println(“Elements of array are : …
//PROGRAM TO FIND THE SUM OF ELEMENTS OF A GIVEN ARRAY class sumArray { int a[ ]={3,6,9,35,11,12,13},s=0,i; int sum( ) { for(i=0;i<=6;i++) { s=s+a[i]; } return s; } public static …
//PROGRAM TO SEARCH AN ELEMENT IN A GIVEN ARRAY class searchArray { public static void main(String args[ ]) { int a[ ]={3,6,8,9},d,f=0,i,c=0; d=9; System.out.println(“Elements in the array are: 3,6,8,9″); System.out.println(“Element …