0% found this document useful (0 votes)
26 views12 pages

11.number Guessing Game

The document outlines a Java project called 'Guess the Number,' where users guess a computer-generated number between 1 and 100. It includes a flowchart, code implementation, hardware and software requirements, and a bibliography for reference. The project also suggests features like limiting attempts, adding rounds, and scoring based on attempts.

Uploaded by

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

11.number Guessing Game

The document outlines a Java project called 'Guess the Number,' where users guess a computer-generated number between 1 and 100. It includes a flowchart, code implementation, hardware and software requirements, and a bibliography for reference. The project also suggests features like limiting attempts, adding rounds, and scoring based on attempts.

Uploaded by

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

Table of Contents

ABSTRACT..............................................................2
FLOWCHART...........................................................3
CODE......................................................................4
OUTPUTS................................................................7
Hardware specs......................................................9
Software requirements.........................................10
Bibliography.........................................................12

1 | Page
ABSTRACT

The fun and easy project “Guess the Number” is a


short Java project that allows the user to guess the
number generated by the computer & involves the
following steps:
1.The system generates a random number from a
given range, say 1 to 100.
2.The user is prompted to enter their given number
in a displayed dialogue box.
3.The computer then tells if the entered number
matches the guesses number or it is higher/lower
than the generated number.
4.The game continues under the user guessing the
number.
5.You can also incorporate further details as:
6.Limiting the number of attempts.
7.Adding more rounds.
8.Displaying score.
9.Giving points based on the number of attempts.

2 | Page
FLOWCHART

3 | Page
CODE

package guessinggames;

import javax.swing.JOptionPane;

/**
*
* @author CBSE2022
*/
public class Guessinggames {

public static void main(String[] args) {


int computerNumber = (int)
(Math.random()*100 + 1);
int userAnswer = 0;
System.out.println("The correct guess would
be " + computerNumber);
int count = 1;

4 | Page
while (userAnswer != computerNumber)
{
String response =
JOptionPane.showInputDialog(null,"Enter a guess
between 1 and 100", "Guessing Game",
JOptionPane.QUESTION_MESSAGE);
userAnswer = Integer.parseInt(response);
JOptionPane.showMessageDialog(null, ""+
determineGuess(userAnswer, computerNumber,
count));
count++;
}
}

public static String determineGuess(int


userAnswer, int computerNumber, int count){
if (userAnswer <=0 || userAnswer >100) {
return "Your guess is invalid";
}
else if (userAnswer == computerNumber )
5 | Page
{
return "Correct!\nTotal Guesses: " + count;
}
else if (userAnswer > computerNumber) {
return "Your guess is too high, try again.\
nTry Number: " + count;
}
else {
return "Your guess is too low, try again.\
nTry Number: " + count;
}

6 | Page
OUTPUTS

7 | Page
Hardware specs

8 | Page
WINDOWS 7 ULTIMATE
RATING : 5.1
PROCESSOR : INTEL CORE I3
RAM : 4GB
TYPE : 32 BIT OS
DISK DRIVES : TOSHIBA
DISPLAY ADAPTERS : INTEL HD GRAPHICS 510
MONITORS : GENERIC PNP MONITORS
USB : INTEL USB 3.0 EXTENSIBLE HOST
CONTROLLER

9 | Page
Software requirements

Windows :
Windows 10 (8u51 and above)
Windows 8.x (Desktop)
Windows 7 SP1
Windows Vista SP2
Windows Server 2008 R2 SP1 (64-bit)
Windows Server 2012 and 2012 R2 (64-bit)
RAM: 128 MB
Disk space: 124 MB for JRE; 2 MB for Java Update
Processor: Minimum Pentium 2 266 MHz
processor
Browsers: Internet Explorer 9 and above, Firefox

Mac :
Intel-based Mac running Mac OS X 10.8.3+, 10.9+
Administrator privileges for installation
64-bit browser

10 | P a g e
Linux :
Oracle Linux 5.5+1
Oracle Linux 6.x (32-bit), 6.x (64-bit)2
Oracle Linux 7.x (64-bit)2 (8u20 and above)
Red Hat Enterprise Linux 7.x (64-bit)2 (8u20 and
above)
Suse Linux Enterprise Server 10 SP2+, 11.x
Ubuntu Linux 12.04 LTS, 13.x
Ubuntu Linux 14.x (8u25 and above)
Ubuntu Linux 15.04 (8u45 and above)
Ubuntu Linux 15.10 (8u65 and above)
Browsers: Firefox

11 | P a g e
Bibliography
hackr.io
stackoverflow.com
github.com
geeksforgeeks.com
w3schools.com

12 | P a g e

You might also like