i wrote my program but the teacher wants us to use at least 2 value returning functions and 1 non-value returning function in your final submission. what does he mean by this. do i have this in my program and if so where. if not how do i go about doing this. 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

>>what does he mean by this
why don't you ask him? But my guess is that you need to add three functions, two functions each return an int and the other function is void

int function1()
{
   return 0;
}
int function2()
{
   return 0;
}
void function3()
{
}

do i have this in my program and if so where.

No. Looks like you've not yet come across the concept of functions. Try reading the chapter related to 'user defined functions' in your textbook.

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.