#include<iostream>
#include<conio.h>
#include<ctime>
#include<cstdlib>
#include<string>
int score=0;
using namespace std;
void display(int &score)
{ 

    switch(score)
    {
    case 98:score=28;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 95:score=24;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 92:score=51;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 83:score=19;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 73:score=1;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 69:score=33;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 64:score=36;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 59:score=17;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 55:score=7;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 52:score=11;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 48:score=9;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 46:score=5;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 44:score=22;cout<<"OPPSSSSS......snaked attacked you...now you are at "<<score<<endl;break;
    case 8:score=26;cout<<"Great work.........you are at "<<score<<endl;break;
    case 21:score=82;cout<<"Great work.........you are at "<<score<<endl;break;
    case 43:score=77;cout<<"Great work.........you are at "<<score<<endl;break;
    case 50:score=91;cout<<"Great work.........you are at "<<score<<endl;break;
    case 62:score=96;cout<<"Great work.........you are at "<<score<<endl;break;
    case 66:score=87;cout<<"Great work.........you are at "<<score<<endl;break;
    case 88:score=100;cout<<"Great work.........you are at "<<score<<endl;break;
    }}


int main()
{

    srand ( static_cast<unsigned int>(time(NULL)) );

    int choice;
    string name1,name2;
    int p1=0;
        int p2=0;

    cout<<"enter name of PLAYER 1  \n:";
        getline(cin,name1);
    cout<<"Enter name of PLAYER 2  \n:";
    getline(cin,name2);
    while((p1<=100)&&(p2<=100))
    {
    //system("cls");
    cout<<"----/\PLAYER1 your turn... \n " ;
    getch();
    int n=rand()%6+1;
    p1=n+p1;
    cout<<"player 1 is at "<<p1<<endl;
    display(p1);
    cout<<"----/\PLAYER2 your turn...press space bar \n " ;
    getch();
int m=rand()%6+1;
    p2=m+p2;
    cout<<"player 2 is at "<<p2<<endl;
    display(p2);
    }
if(p1>p2)
    cout<<name1<<"  wins....good work";
else
        cout<<name2<<"  wins....good work";


    system("pause");
    return 0;



    }

This is just the machine playing with itself. What about real user input? This is a situation where a proper description of the flow of the game is required. Pseudo code is ok, or just text descriptions of how the game should flow, and how user input is interpreted to control the flow of the game. If this were a class assignment, I don't think you'd get much more than a D- (if I were feeling generous the day I graded your work).

in this program bonus is not calculating.............why

#include<iostream>
#include<cstdlib>
#include<ctime>
#include<fstream>
using namespace std;
void display(int bonu[])
{
    ofstream outdata;
    outdata.open("employee.txt",ios::app);

    outdata<<"saleperson\t\t\tbonus\n";
    for(int i=0;i<10;i++)
    {
        outdata<<i<<"\t\t\t";
        outdata<<bonu[i]<<endl;

     }




}
void bon (int arra[][3],int bonus[])
{

for(int i=0;i<10;i++){
for(int j=0;j<3;j++)
{
if((arra[i][j]>=5001)&&(arra[i][j]<=10000))
    bonus[i]=bonus[i]+(arra[i][j]*0.15);
if((arra[i][j]>=1001)&&arra[i][j]<=5000)
    bonus[i]=bonus[i]+(arra[i][j]*0.20);
if((arra[i][j]>=501)&&arra[i][j]<=1000)
    bonus[i]=bonus[i]+(arra[i][j]*0.15);
if((arra[i][j]>=200)&&arra[i][j]<=500)
    bonus[i]=bonus[i]+(arra[i][j]*0.10);
else
    bonus[i]=bonus[i]+arra[i][j];
}
} 

display(bonus);



}


int main()
{
    srand(time('\0'));
    int n;
    ifstream infile;
    ofstream outdata;
    outdata.open("employee.txt",ios::app);
    outdata<<"january\t\t\tfebuary\t\t\tmarch\n";
    for(int i=0;i<10;i++)
    {
    for(int j=0;j<3;j++)
    {
     n=rand()%10000+200;
     outdata<<n<<"\t\t\t";
     }outdata<<endl;
    }
    outdata.close();
    infile.open("employee.txt");
    int bonus[10]={0};
    int arra[10][3]={(0,0)};
    for(int i=0;i<10;i++){
    for(int j=0;j<3;j++){
    infile>>arra[i][j];
     }}

    bon(arra,bonus);
    outdata.close();
    infile.close();
    system("pause");
     return 0;

}
This article has been dead for over six months. Start a new discussion instead.