NUMBER GUESSING GAME
Submitted to
University of Mumbai
Submitted in partial fulfillment of the requirements of the degree
B.E.
(Computer Engineering)
By
Khan Mohammed Owais (23CO39)
Thakur Hardik Raghunath (23CO62)
Shaikh Ashraful Ayaan (22CO45)
Supervisor
Prof. Shahegul Afroz
Department of Computer Engineering
Anjuman-I-Islam’s Kalsekar Technical Campus
School of Engineering and Technology
Plot No. 2 & 3, Sector-16, Near Thana Naka, Khanda Gaon,
New Panvel, Navi Mumbai. 410206
October 2024
Description ::
This Java program implements a simple Number Guessing Game, where the
player tries to guess a randomly generated number between 1 and 100.
Key Features:
1. Random Number Generation: The program generates a random
number between 1 and 100 using Random.nextInt(100) + 1, which the
player needs to guess.
2. User Input Handling: It takes user input via the Scanner class to allow
the player to input guesses.
3. Feedback Mechanism: After each guess, the program provides
feedback on whether the guess is too low, too high, or correct.
4. Guess Count Tracking: The program tracks the number of attempts
the player makes and displays it upon correctly guessing the number.
5. Loop Until Correct Guess: A while loop ensures the game continues
until the player guesses the correct number, keeping the game
interactive.
Packages ::
In the provided Java program, two package is used:
1. java.util.Random:
This package provides the Random class, which is used to generate
random numbers.
In this program, Random rand = new Random(); generates a random
number between 1 and 100 using rand.nextInt(100) + 1.
2. java.util.Scanner:
This package provides the Scanner class, which is used to read user input.
In the program, Scanner scanner = new Scanner(System.in); is used to
capture the player's guess from the console input.
Both of these classes are part of the java.util package, which contains
utility classes for handling data structures, random number generation,
and input handling in Java.
ScreenShots ::
In this screenshot, User has successfully compiled and executed the
NUMBER GUESSING GAME program using the commands
javac Converter.java to compile &
java Converter to run it.
The program starts by welcoming the user and prompting them to Guess one
number between 1 to 100.
In this screenshot,
User has guessed the first no as 76 which is too low and second number
as 95 which is too high.
In this screenshot,
After some random guesses user has entered the correct number ,
It took 9 tries to guess the correct number