i have my whole program written but when it prompts the user if they want to play again(y/n) there is a 1 after it and i cammot figure out why. any help would greatly appreciated
here is my program:

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <conio.h>
using namespace std;

int main ()
{
	int numofgames;
	int compchoice;
	int choice;
	bool done;
	int noOfGuesses=0;
	int ncount=0;
	int sum=0;
	int noofgamesplayed=0;
	int avgNoOfGuesses=0;
	int tie=0;
	int win=0;
	int loss=0;

	char opt;

	//chosing how many games you would like to play welcome you to the game
	cout << "Please choose an ODD number of games you would like to play>";
	cin >> numofgames;
	cout << "Welcome to Rock paper scissors"; 
	cout << endl;
	cout << "You are playing against the computer";
	cout << endl;
	do 
	{
		done = false;
		noOfGuesses = 0;
		// player chooses rock, paper, scissors
		while ((noOfGuesses < numofgames) && (!done))
		{
			++noofgamesplayed;
			compchoice = (rand() + (int)time(0)) % 3;
			cout << "Please type 0 for rock, 1 for paper and 2 for scissors";
			cin >> choice;
			cout << endl;
			noOfGuesses++;
			if (choice == 0) 
			{
				if (compchoice == 0)//Rock
				cout << "It's a tie!" << tie++ << endl;
				else if (compchoice == 1)
					cout << "Paper covers rock! Sorry, you lose!" << loss++ << endl;

				else if (compchoice == 2)
					cout << "Rock pounds scissors! You win!" << win++ <<endl;
			}
			if (choice == 1)//Paper
			{
				if (compchoice == 0)
					cout << "Paper covers rock! You win!" << win++ << endl;
				else if (compchoice == 1)
					cout << "It's a tie!" << tie++ << endl;
				else if (compchoice == 2)
					cout << "Scissors cuts paper! Sorry, you lose!" << loss++ << endl;

			}
			if (choice == 2)//scissors
			{
				if (compchoice == 0)
					cout << "Paper covers rock! Sorry you lose" << loss++ << endl;

			else if (compchoice == 1)
					cout << "Scissors cuts paper! You win!" << win++ << endl;

				else if (compchoice == 2)
					cout << "It's a tie!" << tie++ << endl;
				sum+= noOfGuesses ;
			}
			if (choice > 2)
				cout << "Your guess is INVALID pick again!" << endl;
		}

		// you will be able to play the game again or stop
		cout<<"Would you like to try the game again <Y/N>? ";
		cout<< compchoice<<endl;
		cin>>opt;
		// shows the number of game the player had played, total number of guesses and the average of guessing

	} while( opt != 'n');
	cout<<"\n Number of Games played " <<noofgamesplayed;
	cout<<"\n Total number of guesses:" << numofgames;
	cout<<"\n Guessing Average:" <<numofgames/noofgamesplayed;
	cout<<"\n Number of Games Won:" << win;
	cout<<"\n Number of Games Lost:" << loss;
	cout<<"\n Number of Games Tied:" << tie;
	_getch();
	return 0;

}

Recommended Answers

All 2 Replies

>>and i cammot figure out why.
Because you told it to print it on line 82. Delete that line and it will be ok.

thank you very much. you are a great help

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.