diff --git a/Number Guessing Game/game.java b/Number Guessing Game/game.java new file mode 100644 index 0000000..aa60143 --- /dev/null +++ b/Number Guessing Game/game.java @@ -0,0 +1,50 @@ +import java.util.Scanner; + + +public class game { + + public static void main(String[] args) { + int num = 1+(int)(Math.random()*100); + int tot_trial = 10; + int my_trial = 1; + System.out.println("\n******** Welcome To The Game - Guess The Number ********\n"); + + while(my_trial <= tot_trial) + { + Scanner sc = new Scanner(System.in); + System.out.println("Enter any number between 1 and 100 : "); + int guess = sc.nextInt(); + + if(num==guess) + { + System.out.println("Congrats !!!"); + System.out.println("The entered number matches with the random number"); + System.out.println("\n******** Thank You For Playing The Game ********\n"); + break; + } + else if(guess>num) + { + System.out.println("The entered number is greater than the random number"); + } + else if(guess