Untitled

mail@pastecode.io avatar
unknown
java
3 years ago
843 B
1
Indexable
Never
import java.util.*;
public class problem00 {
    public static void main(String[]args){
        System.out.println("Please write the maximum number on the guessing game");
        Scanner scan = new Scanner(System.in);
        int max = scan.nextInt();
        System.out.println("Write your number and let the program guess it");
        final int rez = scan.nextInt();
        boolean a = false;
        int min =0;
        while(a){
            int random = (int)Math.floor(Math.random()*(max-min+1)+min);
            if(random==rez){
                System.out.println("The computer found yor number and it is: "+random);
                a=true;
            }
            else if(random>rez){
                System.out.println("The computer guess id lower than the secret number");

            }
        }
    }
}