Hi guys! Well they gave me this work, that says as follows:

Write a program to score the paper-rock-scissor game. Each of two users types either P, R, or S. The prgram then announces the winner as well as the basis for determining the winner: Paper covers rock, Rock break scissors, Scissors cut paper, or Nobody wins. Be sure to allow the users to use lowercase as well as uppercase letters. Your program should include a loop that lets the user play again until the user says that she or he is done.

Well ive been trying to do it, I know that I can use switch to do it, but the biggest problem I have is that it has 2 input from different players! And I dont know how to do switch with 2 inputs... so here is what I have done... which does not compile... I know... It's a mess :'(

#include<iostream>
using namespace std;
int main()

{
	char player1, player2, ans;

	cout << "Welcome to Rock Papers & Scissors!"; 
	cout << " It is easy, you and your partner will either choose Rock (enter R),"; 
	cout << " Paper (enter P) or Scissors (enter S). Player 1 goes first, then Player 2."; 
	cout << " Let the best man win!\n";
	cin >> player1;
	cin >> player2;

	do
	{
		if (player1 == ('R' || 'r') && player2 == ('P' || 'p'))
		{
			cout << "Paper covers rock, Player 2 Wins\n";
		}
		else if (player1 == ('P' || 'p') && player2 == ('R' || 'r'))
		{
			cout << "Paper covers rock, Player 1 Wins\n";
		}
		else if (player1 == ('R' || 'r') && player2 == ('S' || 's'))
		{
			cout << "Rock breaks scissors, Player 1 Wins\n";
		}
		else if (player1 == ('S' || 's') && player2 == ('R' || 'r'))
		{
			cout << "Rock breaks scissors, Player 2 Wins\n";
		}
		else if (player1 == ('P' || 'p') && player2 == ('S' || 's'))
		{
			cout << "Scissor cuts paper, Player 2 Wins\n";
		}
		else if (player1 == ('S' || 's') && player2 == ('P' || 'p'))
		{
			cout << "Scissor cuts paper, Player 1 Wins\n";
		}
		else if ((player1 == (('R' || 'r') || ('S' || 's') ||('P' || 'p'))) == ((player2 == (('R' || 'r') || ('S' || 's') || ('P' || 'p'))))
		{
			cout << "It's a Draw! No one wins!\n";
		else
		{
	        	cout << "One or both players have entered an invalid character\n";
		}

		cout << "Do you want to play again? Press 'Y' for yes or 'N' for no\n";
		cin >> ans;
	}while (ans == 'Y' || ans == 'y');

	cout << "Thanks for playing!\n";

	return 0
}

> player1 == ('R' || 'r')
Is not the same as
player1 == 'R' || player1 == 'r'

You might want to consider toupper() to halve the number of tests.

Ok thanks salem I will try out that one.

But in my course they still haven't teached us what toupper is... so I cannot use it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.