×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Ahmed Alsakhawy
Added: Aug 21, 2021 12:21 PM
Modified: Aug 21, 2021 12:21 PM
Views: 3467
Tags: java
  1. Scanner input=new Scanner(System.in);  
  2.     int guess,rand;
  3.     rand=(int)(Math.random()*100);      
  4.     boolean stillplaying=true;
  5.     System.out.println("the random value equal " +rand);
  6.     while (stillplaying==true)
  7.     {
  8.         System.out.println("enter your guess between 0-100 ");
  9.         guess=input.nextInt();
  10.         if (guess>rand)
  11.             System.out.println("your guess is too large");
  12.         else
  13.             if(guess<rand)
  14.                 System.out.println("your guess is too small");
  15.         else
  16.             {
  17.                 System.out.println("Winner Winner chiken dinner!!");
  18.                 stillplaying=false;
  19.             }
  20.     }