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 ; import java.util.Random ; import java.util.Scanner ; public class Ch9_43_Ex3_GuessTheNumber { public static void main ( String [] args ) { Random rand = new Random (); int rand_num = rand . nextInt ( 100 ); System . out . println ( rand_num ); Scanner scan = new Scanner ( System . in ); int guessed_num = - 1 ; int numberOfGuesses = 1 ; while ( guessed_num != rand_num ) { System . out . println ( "Guess the number: " ); guessed_num = scan . nextInt (); if ( guessed_num > rand_num ) { System . out . println ( "Aww ...Too big number." ); numberOfGuesses ++; } else if ( guessed_num < rand_num ) { System . out . println ( "Oops...its a small number." ); numberOfGuesses ++; } } System . out . println ( "yehh...You got the number in...
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 ; import java.util.Scanner ; public class Ch5_22_DoWhileLoop { public static void main ( String [] args ) { Scanner scan = new Scanner ( System . in ); System . out . println ( "Enter any to get natural numbers: " ); int n = scan . nextInt (); int i = 0 ; do { System . out . print ( i + " " ); i ++; } while ( i <= n ); } }
Comments
Post a Comment