0% found this document useful (0 votes)
13 views8 pages

It Skill Report

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

It Skill Report

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

JAWAHAR NAVODAYA

VIDYALAYA
DODDABALLAPURA

IT SKILL
Project
Session : 2024-2025

A Project Report On
“Guess the Number Game”

Submitted by BALAJI V
Class – XII (Science) Under the Guidance of
Mr. SUKHATEERTHA
PGT (Computer
Science)
Table of Contents

1. Introduction 1.1 Overview of the Game


1.2 Objectives of the Game
1.3 Key Concepts Covered in the Game
2. Game Concept 2.1 Objective of the Game
2.2 Game Flow and Structure
3. Code Implementation Breakdown 3.1 Random Number
Generation
3.2 User Input Handling
3.3 Feedback Logic
3.4 Game Loop and End Conditions
4. Possible Extensions and Enhancements 4.1 Difficulty Levels
4.2 Limiting the Number of Tries
4.3 Replay Option
4.4 Graphical User Interface (GUI)
5. Challenges and Learning Outcomes 5.1 Challenges in Game
Design
5.2 Key Learning Outcomes from Implementing the Game
6. Conclusion
6.1 Summary of the Game's Design
6.2 Future Improvements and Extensions
Certificate
This is to certify that BALAJI V student of class XII (Science) has successfully
prepared the report on the Project entitled “Guess the Number Game” under
the guidance of Mr. SUKHATEERTHA (PGT Computer Science). The report is
the result of his efforts & endeavours. The report is found worthy of acceptance
as final Project report for the subject Computer Science of
class XII (Science).

Signature of Internal Examiner Signature of External Examiner


(Mr.SUKHATEERTH) (Mrs.CHETHANA UPADHYA)

Signature of Principal
Mr.R.CHAKRAVARTHY
Acknowledgement
I would like to express a deep sense of thanks and gratitude to my project guide
Mr. SUKHATEERTHA for guiding me immensely through the course of the
project. He always evinced keen interest in my project. His constructive advice
& constant motivation have been responsible for the successful completion of
his project.

My sincere thanks goes to Mr. Chakravarthy(principal) sir for his co-ordination


in extending every possible support for the completion of this project.

I must thank my classmates for their timely help and support for completion of
this project.

Last but not the least, I would like to thank all those who had helped directly or
indirectly towards the completion of this project.

BALAJI V
Class- XII (Science)
Guess the Number Game in Java
1. Game Concept

The "Guess the Number" game is a simple console-based game where a


random number between 1 and 100 is generated by the computer, and the
player has to guess it. The game provides feedback about whether the guess
is too high or too low, and continues until the player guesses correctly.

The key objectives of the game:

● Logical thinking: Players need to refine their guesses based on the feedback
(high/low).
● Instant feedback: After every guess, the program provides feedback, guiding the
player closer to the correct answer.
● Tracking progress: The number of attempts is recorded and displayed when the
correct guess is made.

2. Code Implementation Breakdown

2.1 Random Number Generation

The random number is generated by using the Random class from Java’s standard
library. This number serves as the target for the player to guess.

Random random = new Random();


int numberToGuess = random.nextInt(100) + 1;

The method random.nextInt(100) generates a number between 0 and 99.


Adding +1 shifts the range to 1-100.

2.2 User Input Handling

The Scanner class is used to collect user input. After each guess, the program
compares the player's guess to the random number and provides feedback
accordingly.

Scanner scanner = new Scanner(System.in);


int playerGuess = 0;
while (playerGuess != numberToGuess) {
System.out.print("Enter your guess: ");
playerGuess = scanner.nextInt();
}
2.3 Feedback Logic

The program compares the player’s guess to the target number:

● Too low: The program outputs "Too low! Try again."


● Too high: The program outputs "Too high! Try again."
● Correct guess: The program outputs "Congratulations!" and ends the game.

if (playerGuess < numberToGuess) {


System.out.println("Too low! Try again.");
} else if (playerGuess > numberToGuess) {
System.out.println("Too high! Try again.");
} else {
System.out.println("Congratulations! You guessed the number in " + numberOfTries + "
tries.");
}

2.4 Game Loop and End Conditions

The game continues until the player guesses correctly. After the correct guess, the number of
attempts is displayed.

int numberOfTries = 0;
while (playerGuess != numberToGuess) {
numberOfTries++;
}

3. Possible Extensions and Enhancements

3.1 Difficulty Levels

You could add multiple difficulty levels to adjust the range of the random number. For
example:

● Easy: Numbers between 1 and 50.


● Medium: Numbers between 1 and 100 (current range).
● Hard: Numbers between 1 and 1000.

To implement this, prompt the player for a difficulty level:

System.out.println("Select difficulty: 1. Easy, 2. Medium, 3. Hard");


int difficulty = scanner.nextInt();
int range = (difficulty == 1) ? 50 : (difficulty == 3) ? 1000 : 100;
int numberToGuess = random.nextInt(range) + 1;
3.2 Limit the Number of Tries

You could limit the number of guesses to make the game more challenging. For
instance, you could restrict the player to 10 tries.

int maxTries = 10;


while (playerGuess != numberToGuess && numberOfTries < maxTries) {
// game logic
}

if (numberOfTries >= maxTries) {


System.out.println("Sorry! You've reached the maximum number of tries. The number was:
" + numberToGuess);
}

3.3 Replay Option

After the player guesses correctly, offer them a chance to play again without
restarting the program. This can be achieved by wrapping the game logic in a
loop.

String playAgain = "yes";


while (playAgain.equalsIgnoreCase("yes")) {
// Reset the game logic and number
numberToGuess = random.nextInt(100) + 1;
numberOfTries = 0;
// Repeat the guessing loop
System.out.println("Would you like to play again? (yes/no)");
playAgain = scanner.next();
}

3.4 Graphical User Interface (GUI)

For a more advanced version, you could add a graphical user interface (GUI) using
JavaFX or Swing. A GUI could include buttons for submitting guesses, labels for
displaying feedback, and a more interactive experience.

4. Challenges and Learning Outcomes

4.1 Challenges

● Handling Incorrect Inputs: The current code assumes the player will always
enter a valid integer. Additional validation for non-integer inputs or invalid
guesses (e.g., negative numbers) could be added to improve the game.
● Game Logic Flow: While this implementation is simple, more complex games
would require additional state management (e.g., maintaining multiple levels or
storing game progress).

4.2 Learning Outcomes

● Conditionals: Using if-else statements to provide feedback based on the


player's guess.
● Loops: Repeating the guessing process with while loops until the player
guesses the correct number.
● Randomization: Understanding how the random number generation works to
ensure each game is different.
● User Input Handling: Using the Scanner class to gather player input and
manage user interactions.

5. Conclusion

The "Guess the Number" game is an excellent example of a simple console-based


Java game. It uses basic programming constructs such as loops, conditionals, and
random number generation. Additionally, it provides an excellent foundation for
expanding and adding more complex features, such as difficulty levels, input
validation, and even a graphical interface.

You might also like