Pages

Tuesday, November 12, 2013

jack n poy code in c++

This will be the output:



and this will be the code:

 # include <iostream>
using namespace std;
int main ()
{
    char one, two;
    cout<<"Enter code Player 1: "; cin>>one; cout<<endl;
    cout<<"Enter code Player 2: "; cin>>two; cout<<endl;
    if (one == 'c' && two == 'p')
    {cout<<"Player 1 wins!"; cout<<endl;}
    else if (one == 'c' && two == 's')
    {cout<<"Player 2 wins!"; cout<<endl;}
    else if (one == 'c' && two == 'c')
    {cout<<"It's a TIE!"; cout<<endl;}
    else if (one == 'p' && two == 'c')
    {cout<<"Player 2 wins!"; cout<<endl;}
    else if (one == 'p' && two == 's')
    {cout<<"Player 1 wins!"; cout<<endl;}
    else if (one == 'p' && two == 'p')
    {cout<<"It's a TIE!"; cout<<endl;}
    else if (one == 's' && two == 'c')
    {cout<<"Player 1 wins!"; cout<<endl;}
    else if (one == 's' && two == 'p')
    {cout<<"Player 2 wins!"; cout<<endl;}
    else if (one == 's' && two == 's')
    {cout<<"It's a TIE!"; cout<<endl;}
    cout<<endl;
    system ("pause");
}