The Hidden Mystery: Name - Arko Roy Class - Xi-B ROLL - NO - 05
The Hidden Mystery: Name - Arko Roy Class - Xi-B ROLL - NO - 05
THIS GAME IS A MODIFIED VERSION OF THE HIGH LOW NUMBER GUESSING GAME WHERE YOU CHALLENGE THE COMPUTER OR YOUR GAMING PARTNER TO READ THEIR BRAINS BY GUESSING THEIR CHOOSEN NUMBER. MOMENTS GET INTENSE AND INTERESTING WHEN YOU NEARLY GUESS YOURS FRIENDS NUMBER AND YOUR FRIEND TOO NEARLY GUESSES YOUR NUMBER. SO COME LETS FACE OFF OUR GUESSING ABILITIES]
Arko Roy
NAME CLASS
ROLL.NO - 05
UPLOAD.CPP
Page 1
UPLOAD.CPP
Page 2
cout << "\n\t PRESS 0 - TO GO TO THE MENU " while (ch1 != 0) { ch1 =getch ()- 48 ;cout << ch1 ;
if (ch1 == 0) goto menu ; cout << "\n\t Sorry! Wrong choice. Please choose again " } break ; } case 2: { clrscr ();
long double lvl ,num ; int flag =0; print (); char cc1 ; cout << "\n\n\t1 HELLO FRIEND I AM COMPUTER.I AM HERE TO CHOOSE MY FAVORITE" << "\n\n\t NUMBER.LETS CHECK HOW FAST YOUR BRAIN CAN CATCH MY SELECTION" input : { cout << "\n\n\t2 I WILL CHOOSE A NUMBER BETWEEN 0 T0 (5000 * " << "difficulty level)" << "\n\n\t3 ENTER LEVEL OF DIFFICULTY CORRECTLY (MAX LEVEL 6) " ; cin >> lvl ; } lvl =lvl *5000 ; if (lvl <= 0) goto input ; cout << "\n\t4 ENTER YOUR NAME " ; char name1 [20 ]; gets (name1 ); unsigned int seedval ; time_t t; seedval = (unsigned )time (& t); srand (seedval ); num =random (lvl ); long guess1 ,d1 ; clrscr (); print (); int i=1,pts =0,f; cout << "\n\t WELCOME " << name1 << " I Have Selected a Number According" << " \n\t To The Level Set By You . Come On Guess The Number \n\n" ; cout << "\t GUESS : " ; cin >> guess1 ; while (flag == 0) { clrscr (); print (); i++; d1 =num -guess1 ; cout << "\n\t YOUR HINT \n" ; f = calculate (d1 ,name1 ,pts ); if (i>3) pts = f-15 ; if (guess1 != num )
UPLOAD.CPP
{ flag =0;
Page 3
cout << "\n\n\t Press 0 to view closeness range or any other" << " \n\t key to continue with the game " ; cc1 =getch (); if (cc1 == '0' ) range (); print (); cout << "\n\t Your Previous guess was :" << guess1 ; cout << "\n\n\t Enter Your Next guess " ; cin >> guess1 ; } else { cout << "\n\t CONGRAGULATIONS !! YOU HAVE MADE IT. YOU TOOK " << " guesses" << "\n\n\t TOTAL POINTS EARNED = " << pts ; lvl =pts /i; cout << "\n\n\t YOUR GRAND SCORE = " << lvl ; flag =1; exit (0); } } } case 3: { clrscr (); long guess1 =0,guess2 =0; char name1 [20 ], name2 [20 ]; long n1 ,n2 ,d1 ,d2 ; int m,v,i=0,pts1 =0,pts2 =0; char cc ;float sc ; print (); cout << "\n\n\t PLAYER 1 ENTER YOUR NAME " ; gets (name1 ); cout << "\n\t PLAYER 2 ENTER YOUR NAME " ; gets (name2 ); clrscr (); print (); cout << "\n\t ==========================" << "\n\t | THE INPUT BOX |" << "\n\t ==========================\n" ; cout << "\n\n\t " << name1 << " Enter the 5 digit no. which " << name2 << " will guess " ; n1 =password (); cout << "\n\n\t " << name2 << " Enter the 5 digit no. which " << name1 << " will guess " ; n2 =password (); clrscr (); print (); while (( guess1 != n2 )||( guess2 != n1 )) { clrscr (); print (); cout << "\n\n\t " << name1 << "'s TURN ..... GOOD LUCK !!\n" ; cout << "\n\t Your previous guess was " << guess1 ; cout << "\n\n\t Enter your current guess \n\t GUESS: " ; cin >> guess1 ;
<< i
UPLOAD.CPP
Page 4
d1 =n2 -guess1 ; clrscr (); print (); cout << "\n\t YOUR HINT : \n" ; m = calculate (d1 ,name1 ,pts1 ); pts1 =m-15 ; if (d1 == 0) cout << "\n\t You have won !! " << name1 << " Wait for " << name2 << "'s turn" ; cout << "\n\n\t Press 0 to view the closeness range " << "\n\t Press any other key to go to " << name2 << "'s turn" ; cc =getch (); if (cc == '0' ) range(); clrscr (); print (); cout << "\n\n\t " << name2 << "'s TURN ..... GOOD LUCK !!\n" ; cout << "\n\t Your previous guess was " << guess2 ; cout << "\n\n\t Enter your current guess \n\t GUESS: " ; cin >> guess2 ; d2 =n1 -guess2 ; clrscr (); print (); cout << "\n\t YOUR HINT : \n" ; v = calculate (d2 ,name2 ,pts2 ); pts2 =v-15 ; i++; if (( guess1 == n2 )&&( guess2 == n1 )) { clrscr (); print (); pts1 += 100 ;pts2 += 100 ; cout << "\n\t Well Guys Both of you have guessed the correct numbers\n" ; cout << "\n\t Total Points Earned by " << name1 << " is " << pts1 << "\n\t Total Points Earned by " << name2 << " is " << pts2 << "\n\t No. of guesses = " << i; sc =( pts1 /i); cout << "\n\n\t" << name1 << " Your GRAND SCORE =" << sc ; sc =( pts2 /i); cout << "\n\t" << name2 << " Your GRAND SCORE =" << sc ; exit (0); i=cc ; } if (guess1 == n2 ) { clrscr (); print (); pts1 += 100 ; cout << "\n\n\t Congratulations !! " << name1 << " You have won !!" ; cout << "\n\t Total Points Earned = " << pts1 << " No. of guesses = " << i; sc =( pts1 /i); cout << "\n\n\t YOUR GRAND SCORE = " << sc ; exit (0); } if (guess2 == n1 ) { clrscr (); print (); pts2 += 100 ; cout << "\n\n\t Congratulations << name2 << "you have won !!; !! " cout << "\n\t Total Points = " << pts2 << " No. of guesses = " << i; sc =( pts2 /i); cout << "\n\n\t YOUR GRAND SCORE = " << sc ; exit (0); } cout << "\n\n\t Press 0 to view the closeness range " << "\n\t Press any other key to go to " << name1 << "'s turn" ; cc =getch(); if (cc == '0' )
UPLOAD.CPP
range (); } } case 4: exit (0); } }
Page 5
int calculate (long d,char *name ,int p) { if (d>= 20000 ) { cout << "\n\t Sorry ! " << name << " Destination far ahead . Your Rocket's waiting" p=p+5; } if (d<=(- 20000 )) { cout << " \n\t Whoops !! " << name << " Are You heading to moon ??" << "\n\t Bring back your rocket . You have crossed your destination " ; p=p+5; } else if (( d>= 9000 )&&( d<20000 )) { cout << "\n\t " << name << " Fetch yourself the Spicejet Airlines !!" << "\n\t You Need to go ahead to your destination quickly " ; p+= 10 ; } else if (( d<=(- 9000 ))&&( d>(- 20000 ))) { cout << "\n\t It seems that You are lost in the air " << name << "\n\t Your Aeroplane should head the reverse direction now " ; p+= 10 ; } else if (( d>= 4000 )&&( d<9000 )) { cout << "\n\t Hey !! Train is coming " << name << " . Need to go ahead" ; p+= 20 ; } else if (( d<=(- 4000 ))&&( d>(- 9000 ))) { cout << "\n\t I feel The train engine has got excess power !! " << name << "\n\t Reverse your train . You already crossed the point" ; p+= 20 ; } else if (( d>= 1000 )&&( d<4000 )) { cout << "\n\t " << name << " You are in the car . Enjoy the breeze and go ahead " p+= 30 ; } else if (( d<=- 1000 )&&( d>- 4000 )) { cout << "\n\t " << name << " Are you asleep . Reverse your Car now !!" << "\n\t You crossed the point ... Hurrrrrrrrry" ; p+= 30 ; } else if (( d>= 500 )&&( d<1000 ))
UPLOAD.CPP
Page 6
{ cout << "\n\t Gear up or Gear down .. We have entered the town " << "\n\t " << name << " Ride your bike ahead to reach the destination" ; p+= 40 ; } else if (( d<=- 500 )&&( d>- 1000 )) { cout << "\n\t Stop Stop Stop .. reverse your bike you left it behind " << name ; p+= 40 ; } else if (( d>= 100 )&&( d<500 )) { p+= 60 ; cout << "\n\t Superb !! The Race is on .Come on we are in cycle " << name << "\n\t Point just some 100 metres ahead" ; } else if (( d<=- 100 )&&( d>- 500 )) { cout << "\n\t Whoops !! Got it wrong " << name << " \n\t Turn Your cycle back and get going" ; p+= 60 ; } else if (( d>= 50 )&&( d<100 )) { p+= 75 ; cout << "\n\t Yeah that's the spirit. " << name << " Run ahead I can see the point" } else if (( d<=- 50 )&&( d>- 100 )) { p+= 75 ; cout << "\n\t Oh no a small mistake ! You just left it Run back ! " << name ; } else if (( d>= 1)&&( d<50 )) { p+= 100 ; cout << "\n\t Hats off !! " << name << " Time to walk ahead to the point." ; } else if (( d<=- 1)&&( d>- 50 )) { p+= 100 ; cout << "\n\t " << name << " Get yourself torches!! & Walk back . You nearly got it" } return p; } void print() { clrscr (); cout << "\n\t ==========================" << "\n\t | THE HIDDEN DESTINATION |" << "\n\t ==========================\n" ; cout << "\n\t ============================================================" << "\n\t || The distance from the destination no. follows the order ||" << "\n\t || Walk-Run-Cycle-Bike-Car-Train-Aeroplane-Rocket ||" << "\n\t =============================================================\n" ; } long password() {
UPLOAD.CPP
Page 7
long no ,conv =0,x=10000 ; for (int i =1;i<= 5;i++) { no =getch ()- 48 ; conv =( x*no )+ conv ; x=x/10 ; cout << "*" ; } return conv ; } void range () { clrscr (); print (); cout << "\n\n\t Guide to interpret the hints " ; cout << "\n\t D = Difference between actual number and guessed number " ; cout << "\n\n\t SO Guys if You got :\n" ; cout << "\n\t A Rocket : D >= 20000 or D <= -20000 ( 5 POINTS)" << "\n\t An Aeroplane : 8000 <= D < 20000 or -8000 >= D > -20000 (10 POINTS)" << "\n\t A Train : 4000 <= D < 8000 or -4000 >= D > -8000 (20 POINTS)" << "\n\t A Car : 1000 <= D < 4000 or -1000 >= D > -4000 (30 POINTS)" << "\n\t A Bike : 500 <= D < 1000 or -500 >= D > -1000 (40 POINTS)" << "\n\t A Cycle : 100 <= D < 500 or -100 >= D > -500 (60 POINTS)" << "\n\t A Run : 50 <= D < 100 or -50 >= D > -100 (75 POINTS)" << "\n\t A Walk : 1 <= D < 50 or -1 >= D > -50 (100 POINTS)\n" cout << "\n\t Press any key to continue the game " ; int as =getch (); cout << as ; }
UPLOAD.CPP
Page 8
UPLOAD.CPP
Page 9