I am a first year IT student cramming my last assignments in before the monday afternoon deadline. I am battling with a problem that looks like this: I have to create a program using the case statements to choose a winner from rock, paper, scissors and count the wins,losses,ties to be displayed after each play. the problem is how do I loop the switch. Also, any ideas on how I should count score using variables?
I would really appreciate any help, C++ and I aren't real friendly yet but it will be my language of choice when I graduate.

Here is my working code but I the program doesn't loop after one game. I want to play an many as I want while the game keeps track of the score until I type 'quit'.

// include libraries
#include "stdafx.h"
#include <time.h>
#include <iostream>
#include <cstdlib>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{

    // declare variables
    int computerChoice;
    char userChoice;
    char wins = 0;
    char losses = 0;
    char ties = 0;

    // seed the random number generator with the current time of day
    // to guarantee a different sequence of random numbers each time.
    srand( (int) time(0) );

    // clear the screen and display the title
    system("cls");
    cout << "     Rock, Paper, Scissors" << endl  
         << "            Roshambo" << endl << endl;

    // loop while userChoice is not equal to quit
    while (userChoice != quit)
    {

        // determine the computer's choice. (0=ROCK , 1=PAPER, 2=SCISSORS)
        computerChoice = rand() % 3;

        // ask the user for his or her choice
        cout << "Enter R for rocks or P for paper or S for scissors or press type QUIT to end game: ";
        cin >> userChoice;



        // create a case for each possible player choice
        switch (userChoice)
        {
            case 'r': // user throws ROCK
            case 'R':

                // create a case for each possible computer choice
                switch (computerChoice)
                {
                    case 0:  // Computer picks ROCK
                        cout << "Rock ties rock, we tie!" << endl;
                        break;
                    case 1:  // Computer picks PAPER
                        cout << "Paper covers rock, you lose." << endl;
                        break;
                    case 2:  // Computer picks SCISSORS
                        cout << "Rock smashes scissors, you win!"  << endl;
                        break;
                }
                break;

            case 'P':  // user throws PAPAER
            case 'p':
                // create a case for each possible computer choice
                switch (computerChoice)
                {
                    case 0:  // Computer picks ROCK
                        cout << "Paper covers rock, you win." << endl;
                        break;
                    case 1:  // Computer picks PAPER
                        cout << "Paper ties paper, we tie!" << endl;
                        break;
                    case 2:  // Computer picks SCISSORS
                        cout << "Scissors cut paper, you lose" << endl;
                        break;
                }
                break;

            case 's':  // user throws SCISSORS
            case 'S':
                // create a case for each possible computer choice
                switch (computerChoice)
                {
                    case 0:  // Computer picks ROCK
                        cout << "Rock smashes scissors, you lose." << endl;
                        break;
                    case 1:  // Computer picks PAPER
                        cout << "Scissors cust paper, you win!" << endl;
                        break;
                    case 2:  // Computer picks Scissors
                        cout << "Scissors ties scissors, we tie!"  << endl;
                        break;
                }
                break;

            default:  // user entered something else.
                cout << "Sorry, I can't interpret the character " << userChoice;
                cout << endl;

        } // end case for userChoice
    } // end of loop

return 0;
}

Recommended Answers

All 10 Replies

You may need to change the while loop to a do-while loop. To keep count of your plays, you need to add a counter wherever you need an increment i.e whenever the user plays the rock you do something like counter++ which will increment by 1 whenever the condition is met.

[EDIT]
You also need to add code tags to your code for easier reading. Read more here

// include libraries
#include "stdafx.h"
#include <time.h>
#include <iostream>
#include <cstdlib>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{

	// declare variables
	int computerChoice;
	char userChoice;
	char wins = 0;
	char losses = 0;
	char ties = 0;

	// seed the random number generator with the current time of day
	// to guarantee a different sequence of random numbers each time.
	srand( (int) time(0) );

	// clear the screen and display the title
	system("cls");
	cout << " Rock, Paper, Scissors" << endl
		<< " Roshambo" << endl << endl;

	// loop while userChoice is not equal to quit
	while (userChoice != quit)
	{

		// determine the computer's choice. (0=ROCK , 1=PAPER, 2=SCISSORS)
		computerChoice = rand() % 3;

		// ask the user for his or her choice
		cout << "Enter R for rocks or P for paper or S for scissors or press type QUIT to end game: ";
		cin >> userChoice;



		// create a case for each possible player choice
		switch (userChoice)
		{
		case 'r': // user throws ROCK
		case 'R':

			// create a case for each possible computer choice
			switch (computerChoice)
			{
			case 0: // Computer picks ROCK
				cout << "Rock ties rock, we tie!" << endl;
				break;
			case 1: // Computer picks PAPER
				cout << "Paper covers rock, you lose." << endl;
				break;
			case 2: // Computer picks SCISSORS
				cout << "Rock smashes scissors, you win!" << endl;
				break;
			}
			break;

		case 'P': // user throws PAPAER
		case 'p':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
			case 0: // Computer picks ROCK
				cout << "Paper covers rock, you win." << endl;
				break;
			case 1: // Computer picks PAPER
				cout << "Paper ties paper, we tie!" << endl;
				break;
			case 2: // Computer picks SCISSORS
				cout << "Scissors cut paper, you lose" << endl;
				break;
			}
			break;

		case 's': // user throws SCISSORS
		case 'S':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
			case 0: // Computer picks ROCK
				cout << "Rock smashes scissors, you lose." << endl;
				break;
			case 1: // Computer picks PAPER
				cout << "Scissors cust paper, you win!" << endl;
				break;
			case 2: // Computer picks Scissors
				cout << "Scissors ties scissors, we tie!" << endl;
				break;
			}
			break;

		default: // user entered something else.
			cout << "Sorry, I can't interpret the character " << userChoice;
			cout << endl;

		} // end case for userChoice
	} // end of loop

	return 0;
}

You defined userChoice as a char in line 14. You have not defined quit in line 29, so you're going to get a syntax error there. I assume you meant to put quit in double quotes and treat it like a string, but that won't work either since userChoice is a char, not a string. Have the user enter 'q' to quit and change line 29 to this:

while (userChoice != 'q')

Okay, I hope i encase my code properly. Here is my original working code that is the base game with out the added counters or loop. Where should I state my do-while loop and how do I go about counting the score to be displayed as three separate scores " wins, losses, ties" do I need to ++ each case as a win,loss,tie?

// include libraries
#include "stdafx.h"
#include <time.h>
#include <iostream>
#include <cstdlib>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	
	// declare variables
	int computerChoice;
	char userChoice;
	// seed the random number generator with the current time of day
	// to guarantee a different sequence of random numbers each time.
	srand( (int) time(0) );

	// clear the screen and display the title
	system("cls");
	cout << "     Rock, Paper, Scissors" << endl  
		 << "            Roshambo" << endl << endl;

	// determine the computer's choice. (0=ROCK , 1=PAPER, 2=SCISSORS)
	computerChoice = rand() % 3;

	// ask the user for his or her choice
	cout << "Enter R for rocks or P for paper or S for scissors : ";
	cin >> userChoice;

	// create a case for each possible player choice
	switch (userChoice)
	{
		case 'r': // user throws ROCK
		case 'R':

			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Rock ties rock, we tie!" << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Paper covers rock, you lose." << endl;
					break;
				case 2:  // Computer picks SCISSORS
					cout << "Rock smashes scissors, you win!"  << endl;
					break;
			}
			break;

		case 'P':  // user throws PAPAER
		case 'p':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Paper covers rock, you win." << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Paper ties paper, we tie!" << endl;
					break;
				case 2:  // Computer picks SCISSORS
					cout << "Scissors cut paper, you lose" << endl;
					break;
			}
			break;

		case 's':  // user throws SCISSORS
		case 'S':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Rock smashes scissors, you lose." << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Scissors cust paper, you win!" << endl;
					break;
				case 2:  // Computer picks Scissors
					cout << "Scissors ties scissors, we tie!"  << endl;
					break;
			}
			break;

		default:  // user entered something else.
			cout << "Sorry, I can't interpret the character " << userChoice;
			cout << endl;

	} // end case for userChoice
return 0;
}

Where should I state my do-while loop and how do I go about counting the score to be displayed as three separate scores " wins, losses, ties" do I need to ++ each case as a win,loss,tie?

Insert the switch(userChoice) into a do-while loop and specify a break condition for the same. You'll have to increment the wins, loses and ties in the different cases of switch(computerChoice). Hope this helped.

I was able to figure out the increment and have the code running but the i really don't know how to do the loop. Here is my new code. It runs fine.

Where should the switch and break go in respect to the case switch?

// include libraries
#include "stdafx.h"
#include <time.h>
#include <iostream>
#include <cstdlib>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	
	// declare variables
	int computerChoice;
	char userChoice;
	int win = 0;
	int loss = 0;
	int tie = 0;

	// seed the random number generator with the current time of day
	// to guarantee a different sequence of random numbers each time.
	srand( (int) time(0) );

	// clear the screen and display the title
	system("cls");
	cout << "     Rock, Paper, Scissors" << endl  
		 << "            Roshambo" << endl << endl;

	// determine the computer's choice. (0=ROCK , 1=PAPER, 2=SCISSORS)
	computerChoice = rand() % 3;

	// ask the user for his or her choice
	cout << "Enter R for rocks or P for paper or S for scissors : ";
	cin >> userChoice;

	// create a case for each possible player choice
	switch (userChoice)
	{
		case 'r': // user throws ROCK
		case 'R':

			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Rock ties rock, we tie!" << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Paper covers rock, you lose." << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks SCISSORS
					cout << "Rock smashes scissors, you win!"  << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;

		case 'P':  // user throws PAPAER
		case 'p':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Paper covers rock, you win." << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Paper ties paper, we tie!" << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks SCISSORS
					cout << "Scissors cut paper, you lose" << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;

		case 's':  // user throws SCISSORS
		case 'S':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Rock smashes scissors, you lose." << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Scissors cust paper, you win!" << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks Scissors
					cout << "Scissors ties scissors, we tie!"  << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;

		default:  // user entered something else.
			cout << "Sorry, I can't interpret the character " << userChoice;
			cout << endl;

	} // end case for userChoice
return 0;
}
// include libraries
#include "stdafx.h"
#include <time.h>
#include <iostream>
#include <cstdlib>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{

    // declare variables
    int computerChoice;
    char userChoice;
    int win = 0;
    int loss = 0;
    int tie = 0;

    // seed the random number generator with the current time of day
    // to guarantee a different sequence of random numbers each time.
    srand( (int) time(0) );

    // clear the screen and display the title
    system("cls");

    do
    {

        cout << "     Rock, Paper, Scissors" << endl  
            << "            Roshambo" << endl << endl;

        // determine the computer's choice. (0=ROCK , 1=PAPER, 2=SCISSORS)
        computerChoice = rand() % 3;

        // ask the user for his or her choice
        cout << "Enter R for rocks or P for paper or S for scissors : ";
        cin >> userChoice;

        // create a case for each possible player choice
        switch (userChoice)
        {
        case 'r': // user throws ROCK
        case 'R':

            // create a case for each possible computer choice
            switch (computerChoice)
            {
            case 0:  // Computer picks ROCK
                cout << "Rock ties rock, we tie!" << endl;
                tie++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            case 1:  // Computer picks PAPER
                cout << "Paper covers rock, you lose." << endl;
                loss++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            case 2:  // Computer picks SCISSORS
                cout << "Rock smashes scissors, you win!"  << endl;
                win++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            }
            break;

        case 'P':  // user throws PAPAER
        case 'p':
            // create a case for each possible computer choice
            switch (computerChoice)
            {
            case 0:  // Computer picks ROCK
                cout << "Paper covers rock, you win." << endl;
                win++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            case 1:  // Computer picks PAPER
                cout << "Paper ties paper, we tie!" << endl;
                tie++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            case 2:  // Computer picks SCISSORS
                cout << "Scissors cut paper, you lose" << endl;
                loss++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            }
            break;

        case 's':  // user throws SCISSORS
        case 'S':
            // create a case for each possible computer choice
            switch (computerChoice)
            {
            case 0:  // Computer picks ROCK
                cout << "Rock smashes scissors, you lose." << endl;
                loss++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            case 1:  // Computer picks PAPER
                cout << "Scissors cust paper, you win!" << endl;
                win++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            case 2:  // Computer picks Scissors
                cout << "Scissors ties scissors, we tie!"  << endl;
                tie++;
                cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
                break;
            }
            break;

        default:  // user entered something else.
            cout << "Sorry, I can't interpret the character " << userChoice;
            cout << endl;

        } // end case for userChoice
    }
    while (userChoice != 'q');
    return 0;
}

Stick the loop in lines 26,27,117,118. Add a case for 'q' and change line 36 to tell the user the option to quit.

I made some recommended additions and I almost have it running but my userChoice is not recognizing 'q' for quit

warning C4700: uninitialized local variable 'userChoice' used

how do I make line numbers show up on visual studio
error occurs on line 27

Do I need to initialize the userChoice elsewhere or do I need to change the data type or do I need to name an alias?

// include libraries
#include "stdafx.h"
#include <time.h>
#include <iostream>
#include <cstdlib>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	
// declare variables
int computerChoice;
char userChoice;
int win = 0;
int loss = 0;
int tie = 0;

// seed the random number generator with the current time of day
// to guarantee a different sequence of random numbers each time.
srand( (int) time(0) );

// loop
do while ( userChoice != 'q' )
{
	
	// clear the screen and display the title
	system("cls");
	cout << "     Rock, Paper, Scissors" << endl  
		<< "            Roshambo" << endl << endl;
	
	// determine the computer's choice. (0=ROCK , 1=PAPER, 2=SCISSORS)
	computerChoice = rand() % 3;
	
	// ask the user for his or her choice
	cout << "Enter R for rocks or P for paper or S for scissors : ";
	cin >> userChoice;


	// create a case for each possible player choice
	switch (userChoice)
	{
		case 'r': // user throws ROCK
		case 'R':

			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Rock ties rock, we tie!" << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Paper covers rock, you lose." << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks SCISSORS
					cout << "Rock smashes scissors, you win!"  << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;

		case 'P':  // user throws PAPAER
		case 'p':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Paper covers rock, you win." << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Paper ties paper, we tie!" << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks SCISSORS
					cout << "Scissors cut paper, you lose" << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;

		case 's':  // user throws SCISSORS
		case 'S':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Rock smashes scissors, you lose." << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Scissors cust paper, you win!" << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks Scissors
					cout << "Scissors ties scissors, we tie!"  << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;

		case 'q':  // user throws QUIT
		case 'Q':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Game over, here is the final score:  " << endl;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Game over, here is the final score:  " << endl;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks Scissors
					cout << "Game over, here is the final score:  " << endl;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;
			}
			break;

		default:  // user entered something else.
			cout << "Sorry, I can't interpret the character " << userChoice;
			cout << endl;

	} // end case for userChoice
}
	while ( userChoice != 'q' );

return 0;
}
// loop
do while ( userChoice != 'q' )
{

This line:

do while ( userChoice != 'q' )

should be just this:

do

You already have the "while" part at the bottom of your code:

while ( userChoice != 'q' );

The code I posted ran for me in Visual Studio without error and does not require initialzation of userChoice since userChoice is initialized inside the do-while loop. Try to run it as I posted it. If there's an error, then somehow I copied and pasted it wrong from Visual Studio. It's simply your code with the four lines I noted added in. I did not add the "case 'q'" code in my last post. Add it before your "default" case.

I made the posted changes and now computerChoice is messing with me.
here are the errors followed by the code. I also deleted the clear screen to keep the results on screen.

1>c:\documents and settings\m.benton4\my documents\ctu\cs104\week 8\demo8c\demo8c\demo8c.cpp(34) : error C2061: syntax error : identifier 'computerChoice'
1>c:\documents and settings\m.benton4\my documents\ctu\cs104\week 8\demo8c\demo8c\demo8c.cpp(144) : error C2059: syntax error : 'return'
1>c:\documents and settings\m.benton4\my documents\ctu\cs104\week 8\demo8c\demo8c\demo8c.cpp(145) : error C2059: syntax error : '}'
1>c:\documents and settings\m.benton4\my documents\ctu\cs104\week 8\demo8c\demo8c\demo8c.cpp(145) : error C2143: syntax error : missing ';' before '}'
1
// include libraries
#include "stdafx.h"
#include <time.h>
#include <iostream>
#include <cstdlib>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	
// declare variables
int computerChoice;
char userChoice;
int win = 0;
int loss = 0;
int tie = 0;

// seed the random number generator with the current time of day
// to guarantee a different sequence of random numbers each time.
srand( (int) time(0) );

// loop
do 
	
	// display the title
	
	cout << "     Rock, Paper, Scissors" << endl  
		<< "            Roshambo" << endl << endl;
	
	// determine the computer's choice. (0=ROCK , 1=PAPER, 2=SCISSORS)
	computerChoice = rand() % 3;
	
	// ask the user for his or her choice
	cout << "Enter R for rocks or P for paper or S for scissors : ";
	cin >> userChoice;


	// create a case for each possible player choice
	switch (userChoice)
	{
		case 'r': // user throws ROCK
		case 'R':

			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Rock ties rock, we tie!" << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Paper covers rock, you lose." << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks SCISSORS
					cout << "Rock smashes scissors, you win!"  << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;

		case 'P':  // user throws PAPAER
		case 'p':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Paper covers rock, you win." << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Paper ties paper, we tie!" << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks SCISSORS
					cout << "Scissors cut paper, you lose" << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;

		case 's':  // user throws SCISSORS
		case 'S':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Rock smashes scissors, you lose." << endl;
					loss++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Scissors cust paper, you win!" << endl;
					win++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks Scissors
					cout << "Scissors ties scissors, we tie!"  << endl;
					tie++;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;

		case 'q':  // user throws QUIT
		case 'Q':
			// create a case for each possible computer choice
			switch (computerChoice)
			{
				case 0:  // Computer picks ROCK
					cout << "Game over, here is the final score:  " << endl;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 1:  // Computer picks PAPER
					cout << "Game over, here is the final score:  " << endl;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
				case 2:  // Computer picks Scissors
					cout << "Game over, here is the final score:  " << endl;
					cout << "wins:  " << win << "  losses:  " << loss << "  ties:  " <<  tie << endl;
					break;
			}
			break;
			}
			break;

	while ( userChoice != 'q' );

		default:  // user entered something else.
			cout << "Sorry, I can't interpret the character " << userChoice;
			cout << endl;

	} // end case for userChoice
}


return 0;
}

Looks like you removed the bracket after "do". Keep that bracket. The correction I recommended was just to change that SINGLE line, not delete the bracket too. Look at my prior post. The skeleton is this:

do
{
     // code to repeat in loop.  All switch, case, break, and default
     // statements are INSIDE these brackets.
}
while(userChoice != 'q');

Keep this in mind at the end too. You want nothing between the ending bracket } and the word "while" (spaces and line returns are fine, but no code). You have the word "break;" between } and the word "while". You don't want it. I'm not sure whether you deleted the } before the word "while" or not, but if you did delete it, you need to put it back. I think you don't need all those "break" statements possibly, but they may not hurt anything. The "break" between } and "while" definitely needs to be moved or deleted though. Your "default" case is part of your switch statement, so it needs to be BEFORE the word "while", not after.

On a side note, your code is overflowing the line boundaries a lot. A tab in Daniweb is eight spaces. In Visual Studio under Tools->Options->Text Editor->All Languages->Tabs, you can enter a number like 4 in the "Tab Size" box, then click the "insert spaces" radio button. Then you can go to Edit->Select All, then Edit->Advanced->Format Selection, then cut and paste onto Daniweb and it'll fit much more nicely and look cleaner on your post. Sounds like a lot of work, but after a while you get pretty quick at it. Also, with a lot of code like this, if you use these code tags:

[code=cplusplus] // paste code here

[/code]

This will add line numbers, which allows you to refer to line numbers in your code if you wish. It can come in handy.

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.