Can Someone Correct This I Almost Have It Dne

December 6, 2010 at 16:29:51
Specs: Windows 7
/***********************************************************************
Program: Functions.cpp
Author: Janel Harrison
Date: 12/08/2010
Purpose: This program will simulate the game of paper-rock-scissors. The computer will
play against a human user of the program.
***********************************************************************/
#include <iostream>
#include <cstdlib>
#include <cctype>
#include <fstream>
using namespace std;

void readAndValidateUserMove (char);
int computerChoice(int ,char);
void gameStatus(int, int, int );
/**********************************************************************/
int main()
{
int numberOfAttempts;
char userChoice;
int i =0;
int results=0;

cout<<"\n\t\tEnter the Number of Times You Would Like To Play: "<<endl;
cout<<"\n\t\tGame Choices: Best Of 1"<<
cout<<"\n\t\t\tBest Of 3"<<
cout<<"\n\t\tBest Of 5"<<
cout<<"\n\t\tEnter the Number Of One of the choices above: 1-3-5";
cin>>numberOfAttempts;

// ofstream outFile;
// outFile.open (results"prsresults.txt");
// outFile.close(results"prsresults.txt")


cout<<"\n\t\tGood-Bye. Thank You For Playing"<<endl;

return 0;
}
/**************************************************************************/
void readAndValidateUserMove(char &userChoice)
{ do
{
cout<<"\t\t\tEnter P-Paper, R-Rock, and S-Scissors: ";
cin>>userChoice;

userChoice =toupper(userChoice);

}while((userChoice!='P'||userChoice!='p')&&(userChoice!='R'||userChoice!='r')&&(userChoice!='S'||userChoice!='s'));
return ;
}
/*************************************************************************/
int computerChoice(int randomComputerChoice, char randomChoice)
{
srand(time( 0));
randomComputerChoice= (rand()%3)+1;
if(randomComputerChoice==0)
{
randomChoice='P';
}
else if (randomComputerChoice==1)
{
randomChoice='R';
}
else if (randomComputerChoice==2)
{
randomChoice='S';
}

return ;
}
/*************************************************************************/
char outcome(char userChoice, char randomChoice)
{
if (userChoice==randomChoice)
{
cout<<" \n\t\tIts A Tie"<<endl;
}
switch (userChoice)
{
case 'P':
result=(randomChoice=='R');
cout<<"\n\t\tPaper beats Rock"<<endl;
break;
case 'R':
result=(randomChoice=='S');
cout<<"\n\t\tRock beats Scissors"<<endl;
break;
case 'S'
result=(randomChoice=='P');
cout<<"\n\t\tScissors beats Paper"<<endl;
break;
default: cout<<"\n\t\tYou've Entered A NON-Valid Move"<<endl;
}

return ;
}


See More: Can Someone Correct This I Almost Have It Dne

Report •

#1
December 7, 2010 at 23:32:16
See the difference between these statements…
…………………………………………………………………………………….
Correct statement:
//…………………………………………………………………………………..
cout<<"\n\t\tEnter the Number of Times You Would Like To Play: "<<endl;
cout<<"\n\t\tEnter the Number Of One of the choices above: 1-3-5";
//………………………………………………………………………………………
………………………………………………………………………………………….
Wrong statement:
//……………………………………………………………………………………….
cout<<"\n\t\tGame Choices: Best Of 1"<<
//…………………………………………………………………………………………
Why that statement is wrong? Because you typed ( << ) at the end of that statement. It indicates that you want to type something there but you didn’t type anything. So, it will flag errors. Compare it with the above correct statements. There are few similar wrong statements in your program, correct them. I apologize for grammar and spellings.

.....................................
_Adnan_


Report •
Related Solutions


Ask Question