06-15-2011, 06:19 PM
Code:
// Randam Guessing Game
#include <iostream>
#define NEWLINE "\n\n\n"
#include <cstdlib> // need to use rand() function
#include <ctime>
using namespace std;
/*void Start();
void GetResult();
void HighScore();
int a, b, chance, maxrand;
char difficultychoice, menuchoice, diffchoice;
void Start()
{
a = 0;
b = 0;
chance = 0;
maxrand = 0; */
int main ()
{
srand((unsigned)time(0));
int choice, result;
while (choice != 6)
{
// cout<< "\tGuessing Game Program"; //Title of the Program
cout<< NEWLINE;
cout<< "\tMENU\n"; // Title
cout<< "\t=====\n\n";
cout<< "\t1. Guess the Number [Range between 1 to 100.]\n";
cout<< "\t2. Guess the Alpabet [Range between A to Z.]\n";
cout<< "\t3. Difficulty Level Game\n";
cout<< "\t4. High Score [Current top score]\n"; // high score for both number and alphabet game
cout<< "\t5. Credit\n"; // programmer detail
cout<< "\t6. Quit [Enter any key to exit program!]\n"; // Exit program
cout<< NEWLINE;
cout<< "\tSelect Menu ==> "; // user to input he or her choice of game
cin>> choice;
cout<< NEWLINE;
switch (choice)
{
case 1:
cout<< "\tGuess the Number\n"; // one of the selection choice that user has made
cout<< "\t================\n\n";
cout<< "\tInstructions:\n"; // list of instruction that user must follow
cout<< "\t1. Guess the number based on the give range.\n"; //number range is depend on the programmer
cout<< "\t2. You are allowed to make one guess at a time.\n";
cout<< "\t3. Each game has 5 chance to guess the corrent number.\n"; // user is given 5 or more chance to guess the number
cout<< "\t4. Once you have used up all your chancce, you lose the game!\n";
cout<< NEWLINE;
cout<< "\tGood Luck to You!";
cout<< NEWLINE;
cout<< "\tPlease guess from 1 to 100. 5 chances left. What is the number?"; //use is ask to guess the number
cout<< NEWLINE;
break;
// case 2:
cout<< "\tGuess the Alphabet\n"; // one of the selection choice that use has made
cout<< "\t================\n\n";
cout<< "\tInstructions:\n"; // list of instruction that user must follow
cout<< "\t1. Guess the alphabet based on the give range.\n"; //number range is depend on the programmer
cout<< "\t2. You are allowed to make one guess at a time.\n";
cout<< "\t3. Each game has 5 chance to guess the corrent alphabet.\n"; // user is given 5 or more chance to guess the number
cout<< "\t4. Once you have used up all your chancce, you lose the game!\n";
cout<< NEWLINE;
cout<< "\tGood Luck to You!";
cout<< NEWLINE;
cout<< "\tPlease guess from A to Z. 5 chances left. What is the alphabet?"; //use is ask to guess the number
cout<< NEWLINE;
// break;
// case 3:
cout<< "\tDIFFICULTY LEVEL\n"; // sub menu game
cout<< "\t===================\n";
cout<< "\tSelect a Difficulty Level" << endl;
cout<< "\tLevel 1: Easy (1-15)\n"; // range from 1 to 15
cout<< "\tLevel 2: Normal (1-20)\n"; // range from 1 to 20
cout<< "\tLevel 3: Hard (1-40)\n"; // range from 1 to 40
cout<< "\tTo return to Main Menu, type M\n"; // to return back to main menu
cout<< NEWLINE;
cout<< "\tSelect level to play\n";
/* cin>>diffchoice;
switch (diffchoice)
{
case '1':
maxrand = 15; chance = 5;
break;
case '2':
maxrand = 20; chance = 4;
break;
case '3':
maxrand = 40; chance = 3;
break;
default: exit(0);
} */
//break;
case 4:
cout<< "\tHigh Score\n";
cout<< "\t===========\n";
cout<< "\tGuess the Number Best Score: " /*<< <<*/ "chance use up" << endl;
cout<< "\tGuess the Alphabet Best Score: ";
cout<< NEWLINE;
system ("pause");
system ("cls");
break;
case 5:
system ("cls");
cout<< NEWLINE;
cout<< "\tCREDITED BY\n";
cout<< "\t================\n\n";
cout<< "\tName: Siti Radina A.Abdul Rahman\n"; // programmer name
cout<< "\tStudent ID: 00 - 300 908[ Y ]\n"; // programmer ID number
cout<< "\tCourse: BSc(Hons) in Information Technology 11/01\n"; // programmer Course study
cout<< "\tCountry: Brunei Darussalam\n"; // programmer home country
cout<< NEWLINE;
system ("pause");
system ("cls");
break;
case 6:
exit;
break;
default:
system("cls");
cout<< NEWLINE;
cout<< "\tWRONG INPUT! Please Select 1 to 6 only";
cout<< NEWLINE;
// system("pause");
break;
}
}
return 0;
}0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
