Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (29 sloc) 778 Bytes
import java.util.Random;
import java.util.Scanner;
public class trial
public static void main(String[] args)
// TODO Auto-generated method stub
Random rand = new Random();
Scanner input = new Scanner(;
int target = rand.nextInt(100)+1;
int guess;
System.out.println("Please enter a number >> ");
guess = input.nextInt();
System.out.println("You have entered " + guess);
if (guess == target)
System.out.println("You got the right number!!");
else if (guess < target)
System.out.println("Try another higher number");
System.out.println("Try a smaller number");
for (int i = 0; i < 10; i++);
You can’t perform that action at this time.