Sei sulla pagina 1di 17

PROJECT REPORT

SUBMITTED BY:

T.AKASH

S.VIGNESH

M.SYED MOHAMED

D.PRATHIK KAMAK

SIGNATURE OF THE TEACHER:

SIGNATURE OF THE CO-ORDINATOR:

SIGNATURE OF THE PRINCIPAL:


ACKNOWLEDGEMENT

First and foremost, we would like to thank our


correspondent Mr.M.V.M.Senthil Prakesh and the
Director Mrs.Thilagavathy,for providing best facilities and
technical environmental start this project work.
We express our heartfelt gratitude to our Principal
Mrs.Somasundari , of our institution for her constant
support.
We extend our thanks to our Co-ordinator
Mrs.C.Meena, for rendering her support by engaging us.
We would like to express our whole thanks to the
project supervisor, Ms.B.R.Jeyanthi to come up with our
project victoriously.
We extend our thanks to all the teaching and non-
teaching staff members in our school for their valuable
help and support.
At the outset, we set our thanks to God almighty who
blessed us with a healthy constitution and bestowed
upon us requires the skills to complete this project.
NUMBER GUESSING GAME

BRIEF DESCRIPTION:
The game is a single player game called “Number
guessing name“.
 It is an easy game where the player find it interesting
to play.

HOW TO PLAY:
 The computer chooses a random number within a
known range.
 The player tries to guess the number.
 If the guess is incorrect, then the computer tells the
whether the guess was too high or too low.
 Eventually, the player guesses the correct number.
 The key strategy in this game is to generate a clever
guess.
ALGORITHM:
 Algorithms are the set of rules that
define how a particular problem can be
solved in finite number of steps.
 A program is the expression of an
algorithm in a programming language.

REPRESENTATION OF AN ALGORITHM:
 Normal English
 Program
 Flowchart
 Pseudo code
 Decision Table.
ALGORITHM:
STEP 1: Start.

STEP 2: Enter a number between 1-10

STEP 3: You will get three chances to play the game

STEP 4: If the entered number is invalid,enter


another number between 1-10

Step 5: After three chances,if you will to play the


game again,type yes

Step 6:If not,type no

Step 7:stop
FLOWCHART:
Flowchart is a pictorial
representation of step by a step solution of
a problem.

Flowchart is a symbol oriented design that


identifies the type of statement by the
shape of the symbol containing the
statement.

Flowchart is used as a road map for the


programmer.

There are various symbols that carry


different messages and are used for
different purposes.

FLOWCHART:
Start
Enter a number
between 1-10

You will get three


chances to play
the game

If the entered number


is invalid,enter another
number between 1-10

After three chances,if


you will to play the game
again,type yes

Willing to yes
play again

no
Stop
PROGRAMMING CODE:
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <cstdlib>
#include <windows.h>
using namespace std;
int main()
{
int userInput;
int number;
int min = 1;
int max = 10;
float playerTimesToPlay = 0;
int playAgain;
float tries = 3;
do
{ system("CLS");
cout << "Welcome to my number guessing game!" << endl;
cout <<
"===================================================
=" << endl;
cout << "The computer is generating a number between 1 and
10." << endl;
cout <<
"===================================================
=" << endl;
srand(time(0));
number = rand()% (max - min + 1)+min;
playerTimesToPlay = 0;
tries = 3;
do
{
cout << "Please take a guess: ";
if (!(cin >> userInput))
{cout << endl;
cout << "Please enter numbers only." << endl;
cin.clear();
cin.ignore(10000,'\n');
}
while(userInput > 10 || userInput < 0)
{
cout << "Pick a number BETWEEN 1 TO 10." << endl;
cout << endl;
userInput = NULL;
playerTimesToPlay=0;
}
tries--;
cout << endl;
cout << "You picked: " << userInput << endl;
cout << "======================" << endl;
playerTimesToPlay++;
if(userInput != number && tries > 0 && userInput <= 10)
{
cout << "Sorry! Invalid choice. Please try again. You have " <<
tries << " guess(es) remaining." << endl;
cout << endl;
}
else if(userInput != number && tries == 0)
{
cout << "Sorry! Invalid choice." << endl;
cout << "You have " << tries << " guesses remaining. You lose."
<< endl;
cout << endl;
cout << "Play again? " << endl;
cout << "1. Yes" << endl;
cout << "2. No" << endl;
cout << ": " ;
cin >> playAgain;
}
if(userInput == number)
{
cout << "Congratulations! You guessed the correct number!" <<
endl;
cout << "Thanks for playing!" << endl;
Sleep(2500);
}
}
while (playerTimesToPlay < 3 && userInput != number);
}
while (playAgain == 1);
system("Pause(0)");
return 0;
}
EXECUTION
OUTPUT:

-----------X-----------

Potrebbero piacerti anche