You are on page 1of 1

import java.util.

Random;
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Random rand = new Random();
System.out.print ("This application will close if you will be able to guess
the " + "\n" +
"correct number from (4-7), this computer generates");
System.out.print ("\n" +
"-------------------------------------------------------------------");
int gen=0;
int input=0;
int num=10;
while (gen<=2) {
gen = rand.nextInt(num);
} Scanner scan =new Scanner (System.in);

do { System.out.print ("\n" + "Enter a number from (4-7): ");


num=scan.nextInt();
System.out.print ("\n" + "---------------------GENERATING RANDOM
NUMBER-----------------------");
if (num<=5) {
System.out.print ("\n" + "ERROR TRY AGAIN ");
System.out.print ("\n" +
"------------------------------------------------------------------");
} else if (num>7) {
System.out.print ("\n" + "ERROR TRY AGAIN");
System.out.print ("\n" +
"-------------------------------------------------------------------");
}
else if (num!=gen) {
System.out.print ("\n" + "INCORRECT! Guess Again :)");
System.out.print ("\n" +
"-------------------------------------------------------------------");
}
} while (num!=gen); {
System.out.print ("\n" + "You got it right!! This application is
closing...");
}
}
}

You might also like