Posted by: 6ixMediaSA Category: Code Comments: 0

import java.util.*;
public class Guess {
    public static void main(String[] args) {
        int secret = new Random().nextInt(10) + 1;
        Scanner s = new Scanner(System.in);
        while (true) {
            System.out.print("Guess 1-10: ");
            int g = s.nextInt();
            if (g == secret) break;
            System.out.println(g < secret ? "Higher!" : "Lower!");
        }
        System.out.println("Correct!");
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Let’s Get in Touch

We’re interested in talking
about your business.