I am getting syntax errors and stuff with this and i am trying to make a program where its rock, paper, scissors where the computer plays the user. any help would be awesome

#include <iostream>
#include <ctime>

using namespace std;

enum Choice { Rock, Paper , Scissors }; // Rock=0, Paper=1, Scissors=2
enum Decision { Draw, Win, Lose }; // Draw=0, Win=1, Lose=2

char DoMenu();
void CheckWinner (int PlayerChoice);

int main()
{
	// Use computers random choice generator
	srand(time(0));

	// declare variables
	char choice;

	do
	{
		choice = DoMenu();

		switch (choice)
		{
		case 'R': // fall through
		case 'r': cout << "\nPlayer: Rock\n"; CheckWinner(Rock); break;
		case 'P': // fall through
		case 'p': cout << "\nPlayer: Paper\n"; CheckWinner(Paper); break;
		case 'S': // fall through
		case 's': cout << "\nPlayer: Scissors\n"; CheckWinner(Scissors); break;
		default : cout << "\n";
		}

	} while ((choice != 'Q') && (choice != 'q'));


	// end program
	return 0;
}

char DoMenu()
{
	char MenuChoice;
	cout << "(R)ock\n";
	cout << "(P)aper\n";
	cout << "(S)cissors\n";	
	cout << "----------\n";
	cout << "Choice: ";
	cin >> MenuChoice;
	return MenuChoice;
}

void CheckWinner(Choice PlayerChoice)
{
	int random = rand()%3;

	switch (random)
	{
	case Rock:      cout << "Computer: Rock\n";       break;
	case Paper:     cout << "Computer: Paper\n";      break;
	case Scissors:    cout << "Computer: Scissors\n";  break;
	}
}

if (PlayerChoice == Paper);
{
	switch (random)
	{
	case Rock:    outcome = Win;   break;
	case Paper:   outcome = Draw;  break;
	case Scissors:   outcome = Lose;   break;
	}
}

if (PlayerChoice == Scissors);
{
	switch (random)
	{
	case Rock:    outcome = Lose;   break;
	case Paper:    outcome = Win;   break;
	case Scissors:    outcome = Draw;   break;
	}
}

switch (outcome);
{
case Win: cout << "Player Wins!\n\n";   break;
case Lose: cout << "Player Loses!\n\n";    break;
case Draw: cout << "Draw\n\n";          break;
}

If your getting syntax errors and stuff. Please post them.

sorry here ya go. Im very new at this
1>c:\users\harrison\documents\visual studio 2010\projects\rockpaperscissors\rockpaperscissors\rockpaperscissors.cpp(15): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\harrison\documents\visual studio 2010\projects\rockpaperscissors\rockpaperscissors\rockpaperscissors.cpp(66): error C2059: syntax error : 'if'
1>c:\users\harrison\documents\visual studio 2010\projects\rockpaperscissors\rockpaperscissors\rockpaperscissors.cpp(67): error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\harrison\documents\visual studio 2010\projects\rockpaperscissors\rockpaperscissors\rockpaperscissors.cpp(76): error C2059: syntax error : 'if'
1>c:\users\harrison\documents\visual studio 2010\projects\rockpaperscissors\rockpaperscissors\rockpaperscissors.cpp(77): error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\harrison\documents\visual studio 2010\projects\rockpaperscissors\rockpaperscissors\rockpaperscissors.cpp(86): error C2059: syntax error : 'switch'
1>c:\users\harrison\documents\visual studio 2010\projects\rockpaperscissors\rockpaperscissors\rockpaperscissors.cpp(87): error C2447: '{' : missing function header (old-style formal list?)

Number one, your missing the includes

#include <cstdlib>

What looks wrong here?

if (PlayerChoice == Paper);

Please use code tags and proper formating when posting code.

ok i added that and still get the same errors

Yup that's it. You also have this at the bottom of your code.

if (PlayerChoice == Paper)
{
  switch (random)
  {
	case Rock: outcome = Win; break;
	case Paper: outcome = Draw; break;
	case Scissors: outcome = Lose; break;
  }
}

if (PlayerChoice == Scissors)
{
  switch (random)
  {
	case Rock: outcome = Lose; break;
	case Paper: outcome = Win; break;
	case Scissors: outcome = Draw; break;
  }
}

switch (outcome)
{
  case Win: cout << "Player Wins!\n\n"; break;
  case Lose: cout << "Player Loses!\n\n"; break;
  case Draw: cout << "Draw\n\n"; break;
}

It really should belong to a function.

Note where your function ends.

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

enum Choice { Rock, Paper , Scissors }; // Rock=0, Paper=1, Scissors=2
enum Decision { Draw, Win, Lose }; // Draw=0, Win=1, Lose=2

char DoMenu();
void CheckWinner (int PlayerChoice);

int main()
{
  // Use computers random choice generator
  srand(time(0));

  // declare variables
  char choice;

  do
  {
	choice = DoMenu();

	switch (choice)
	{
	  case 'R': // fall through
	  case 'r': cout << "\nPlayer: Rock\n"; CheckWinner(Rock); break;
	  case 'P': // fall through
	  case 'p': cout << "\nPlayer: Paper\n"; CheckWinner(Paper); break;
	  case 'S': // fall through
	  case 's': cout << "\nPlayer: Scissors\n"; CheckWinner(Scissors); break;
	  default : cout << "\n";
	}

  } while ((choice != 'Q') && (choice != 'q'));


  // end program
  return 0;
}

char DoMenu()
{
  char MenuChoice;
  cout << "(R)ock\n";
  cout << "(P)aper\n";
  cout << "(S)cissors\n";
  cout << "----------\n";
  cout << "Choice: ";
  cin >> MenuChoice;

  return MenuChoice;
}

void CheckWinner(Choice PlayerChoice)
{
  int random = rand()%3;

  switch (random)
  {
	case Rock: cout << "Computer: Rock\n"; break;
	case Paper: cout << "Computer: Paper\n"; break;
	case Scissors: cout << "Computer: Scissors\n"; break;
  }
}
//function ends here...So what's all this stuff down there
if (PlayerChoice == Paper)
{
  switch (random)
  {
	case Rock: outcome = Win; break;
	case Paper: outcome = Draw; break;
	case Scissors: outcome = Lose; break;
  }
}

if (PlayerChoice == Scissors)
{
  switch (random)
  {
	case Rock: outcome = Lose; break;
	case Paper: outcome = Win; break;
	case Scissors: outcome = Draw; break;
  }
}

switch (outcome)
{
  case Win: cout << "Player Wins!\n\n"; break;
  case Lose: cout << "Player Loses!\n\n"; break;
  case Draw: cout << "Draw\n\n"; break;
}

Can you see the benefits of proper formating and code tags?

ok so how do i fix it? do i add another function or what ?

Don't let your teacher catch you :P

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.