Number_Guessing_Game_Project
Number_Guessing_Game_Project
Ibrahimpatnam
This project involves creating a simple number guessing game in Java. In this game, the computer
selects a random number, and the user has to guess it within a limited number of attempts. It’s a fun,
interactive project suitable for beginners and offers practice with conditionals, loops, and user
input.
Project Objectives:
- Generate a random number between 1 and 100.
- Allow the user a limited number of attempts to guess the number.
- Provide feedback on each guess ('too high', 'too low', or 'correct').
- Display a win message if the guess is correct within the attempts.
- Reveal the correct answer if the attempts are exhausted.
Code Implementation:
import java.util.Random;
import java.util.Scanner;
scanner.close();
}
}
Explanation:
1. A `Random` object is used to generate a random number between 1 and 100.
2. The user is given a set number of attempts (5 by default) to guess the number.
3. After each guess, the program provides feedback on whether the guess was too high, too low, or
correct.
4. If the user guesses correctly, a congratulatory message is displayed.
5. If all attempts are used without a correct guess, the correct number is revealed.
23WJ1A6731
CSD-1