Posts

Showing posts from November, 2024

Number Guessing Game in Java Tutorial (Beginning to End)

Image
//In this video I will show you how we create a simple game using Java Console import java.util.Random; import java.util.Scanner; public class GuessTheNumber {   public static void main(String args[]) {    Scanner scanner = new Scanner(System.in);    Random random = new Random();        int randomNumner = random.nextInt(100)+1;    int attempts = 0;    boolean hasGuessed = false;        System.out.println("Wellcome to the Guess the Numner Game");    System.out.println("i am thinking of a number between 1 and 100");          while(!hasGuessed){              System.out.print("Enter your Guess");     int guess = scanner.nextInt();     attempts++;          if(guess<randomNumner){                  System.out.println("Too low");     }else i...