0

iam student in uni, need to know how to write a program for a game that has lucky number and unlucky number in two dimentional array which consists of 25 cells...
please help me!

5
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by ctaylo21
0

Hey you even didn't wrote what game mechanics you should expect. Or do you think that we are some kind of wizards ?

-1

thanks all for the reply... this is what i have ...

# include <iostream>
using namespace std; // declare library
void nextLine(){  
	cout<<endl;
}
int main(){
	cout<<"The name of this game is (seek and find). it has lucky & unlucky number \n"; // intro to the game
	cout<<"If you hit the lucky number, you will win! \n"; // intro to the game
	cout<<"If you hit the unlucky number, you will lose!\n"; // intro to the game
	cout<<"Otherwise you have 2 more chances to win!\n"; // intro to the game
	nextLine(); // call nextLine function
	cout<<"you have this table bellow which consists of 25 numbers"<<endl; // prompt uer to enter a number
	nextLine();  // call nextLine function
	int table [5][5]; // declare a two dimentional array 5 by 5
	int num; // declare num
	int const lucky number=2; // declare & intialize constant lucky number
	int const unlucky number=4; // declare & intialize constant unlucky number 
	for (int i=0;i<5;i++) // using for loop to intialize the table
		for (int j=0;j<5;j++) // declare and intialize i
			table [i][j]=0; // declare and intialize j
	for (int i=0;i<5;i++) // make a condition for i
	{
		for (int j=0;j<5;j++) // make condition for j
			cout<<table [i][j]<<"\t"; // output i and j
		cout <<endl;
	}
	nextLine(); // call nextLine function
	cout<<"enter a number between 1-25 please!"<<endl; // propmt user to enter a number btwn 1-25
	cin>>num; // read numer



	rand( int const lucky number) // calling random function
	  {
		for (table=0;<table<25;table++){ // make condtion for random
			cout<<const lucky number<<endl; // output the lucky number randomly
		}

			rand (int const unlucky number) // calling random function
			{
				for (table=0;<table<25;table++){ // make condtion for random
			cout<<const unlucky number<<endl;  // output the unlucky number randomly
			}
				switch ( game) // using switch to output the result
				{
				case 1: // if the user hits the lucky number
					cout<<" you win the game!"<<endl; // output message that the user won
					break; // end the game
				case 2: // if the user hits the unlucky number
					cout<<" you lost the game\n"; //output message that user lost
					
					cout<<" do you wanna play another game?\n"; // output message to give user option of playing again
					
					cout<<" if yes then enter 1, if no enter 0\n"; // propmt user to enter 1 or 0 based ont the message
					if (num==1) continue; // continue if entered 1
					else if (num==0) break; // break if entered 0
					break; // end
				case 3: // if user entered a nother number
					if (num!= lucky number && unlucky number)// if the number didnt much
					cout<<" enter another number"<<endl; // propmt user to try again
					else if ( num!= lucky number && unlucky number) // if the number didnt much
						cout<<" you lost the game!\n" // output message that user lost
						cout<<"you have 3 times wrong hits"<<endl; //output the record
					    cout<<" do you wanna play another game?\n"; // give user options of playing
					    cout<<" if yes then enter 1, if no enter 0\n";  // propmt user to enter 1 or 0 based ont the message
					     if (num==1) continue; // continue if entered 1
					     else if (num==0) break; // break if entered 0
				}
				return 0;
			}

Edited by Nick Evan: added code-tags

Votes + Comments
Please use code tags. You still haven't explained your problem...
0

I can see several errors in the code, have you tried compiling it so you can see what errors you have?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.