No matter which options you enter, it always displays the result for paper beating rock.

#include <iostream>
#include <iomanip>
using namespace std;

int main ()
{

	/* declaring variables */

	char first;
	char second;
	char paper = 'p';
	char paperP = 'P';
	char rock = 'r';
	char rockR = 'R';
	char scissors = 's';


	/* Instructions */

	cout << "Player one types in p for paper, r for rock, or s for scissors." << endl;
	cout << "Player two types in p for paper, r for rock, or s for scissors." << endl;
	cout << "You may use lower case letters or upper case." << endl;
	cin >> first >> second;

	/* Code to determine which player chose which option */



	switch (first)
	{
	case 'p':
	case 'P': first=paper;
		break;
	case 'r':
	case 'R': first=rock;
		break;
	case 's':
	case 'S': first=scissors;
		break;
	}
	switch (second)
	{
	case 'p':
	case 'P': second=paper;
		break;
	case 'r':
	case 'R': second=rock;
		break;
	case 's':
	case 'S': second=scissors;
		break;
	}


	/* Code to determine winnner, loser, or tie */

	if ((first=paper) && (second=rock))
	{
		cout << "Player 1 wins. Paper covers rock" << endl;
	}
	else if ((first=rock) && (second=scissors))
	{
		cout << "Player 1 wins. Rock breaks scissors." << endl;
	}
	else if ((first=scissors) && (second=paper))
	{
		cout << "Player 1 wins. Scissors cut paper." << endl;
	}
	else if ((first=paper) && (second=paper) || (first=rock) && (second=rock) || (first=scissors) && (second=scissors))
	{
		cout << "Nobody wins." << endl;
	}
	else if ((first=rock) && (second=paper))
	{
		cout << "Player 2 wins. Paper covers rock" << endl;
	}
	else if ((first=scissors) && (second=rock))
	{
		cout << "Player 2 wins. Rock breaks scissors." << endl;
	}
	else if ((first=paper) && (second=scissors))
	{
		cout << "Player 2 wins. Scissors cut paper." << endl;
	}
	else
	{
		cout << "invalid" << endl;
	}
}

New to c++ so it might be a little messy

You need to use doubled equal sign for the equality comparison. As in:

if ((first==paper) && (second==rock))

What you have assigns paper to first (and evaluates as TRUE) and assigns rock as second (which also evaluates as TRUE), so your first test always runs.

if ((first=paper) && (second=rock))

should be if ((first==paper) && (second==rock))

ah. thank you very much.

guess i should stop falling asleep in lecture :P

ah. thank you very much.

guess i should stop falling asleep in lecture :P

That's what I keep telling my students. It never works.:(

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.