I have uploaded all my projects in C, C++, HTML, CSS, Java, and Android Development Projects in a topic-wise sequential manner.
Further posts are uploaded on https://mohitx001.blogspot.com/
package com.company.Ch6_29_PracticeSet ; import java.util.Scanner ; public class PS_Ch6_Q8 { public static void main ( String [] args ) { Scanner scan = new Scanner ( System . in ); System . out . println ( "Enter the values in array" ); int [] arr = new int [ 5 ]; for ( int i = 0 ; i < arr . length ; i ++) { arr [ i ] = scan . nextInt (); } boolean isSorted = true ; for ( int i = 0 ; i < arr . length - 1 ; i ++) { if ( arr [ i ] > arr [ i + 1 ]) { isSorted = false ; break ; } } if ( isSorted ) { System . out . println ( "The array is Sorted." ); } else { System . out . println ( "The array is not Sorted." ); } } }
package com.company.Ch6_29_PracticeSet ; import java.util.Scanner ; public class PS_Ch6_Q4 { public static void main ( String [] args ) { Scanner scan = new Scanner ( System . in ); int [][] matrix1 = new int [ 2 ][ 3 ]; int [][] matrix2 = new int [ 2 ][ 3 ]; int [][] sum = new int [ 2 ][ 3 ]; System . out . println ( "Enter the elements for matrix 1" ); for ( int i = 0 ; i < matrix1 . length ; i ++) { for ( int j = 0 ; j < matrix1 [ i ]. length ; j ++) { System . out . print ( "Enter the element for R" + ( i + 1 ) + "C" + ( j + 1 ) + " : " ); matrix1 [ i ][ j ] = scan . nextInt (); } } System . out . println ( "Enter the elements for matrix 2" ); for ( int i = 0 ; i < matrix2 . length ; i ++) { for ( int j = 0 ; j < matrix2 [ i ]. length ; j ++) { System . out . pr...
package com.company.Ch9_44_PracticeSet ; import java.util.Scanner ; class rectangle { int length ; int breadth ; public rectangle ( int length , int breadth ) { this . length = length ; this . breadth = breadth ; } public int getLength () { return length ; } public int getBreadth () { return breadth ; } public rectangle () { Scanner scan = new Scanner ( System . in ); System . out . println ( " \n Enter the length of rectangle: " ); length = scan . nextInt (); System . out . println ( "Enter the breadth of rectangle : " ); breadth = scan . nextInt (); } public int area () { return length * breadth ; } public int perimeter () { return 2 * ( length + breadth ); } public void display () { System . out . println ( "The area of rectangle having length " + this . getLength () + " and breadth " + t...
Comments
Post a Comment