Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.*;
- import java.util.Scanner;
- public class Rando {
- public static void main(String args[])
- {
- Scanner sc = new Scanner(System.in);
- int random_no = (int)(Math.random()*10 +1);
- boolean flag = true;
- //System.out.print(random_no);
- while(flag)
- {
- System.out.print("\nEnter your guess (between 1-10) : ");
- int inp = sc.nextInt();
- if(inp == random_no)
- {
- System.out.println("\n\tYou guessed it right!");
- flag = false;
- }
- else if(inp < random_no)
- System.out.println("\n Too Low!");
- else
- System.out.println("\n Too High!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement