Reference no: EM13945676
Please look through the code and debug and add anything into it. Make sure it says if the letter is invalid. I am an online learner. The book does not tell me everything. .
// ********************************************************************
//
// PaperRockScissors.cpp
//
// This program simulates the game of paper, rock, scissors. At
// each turn each player enters R, P, or S (either upper or lower
// case) to indicate their choice. The program announces the winner
// along with a message indicating the reason (such as Paper covers
// rock).
//
// ********************************************************************
#include <iostream>
using namespace std;
void printWelcome();
// Postcondition: A welcome and brief instructions are printed to the screen.
char CheckUserInput();
int main (int argc, char *argv[])
{
//
// Variable Declarations
//
char play1Choice, play2Choice;
char playAgain, charUserInput;
charUserInput = play1Choice, play2Choice;
//
// Print a welcome
//
printWelcome();
//
// Play the game as long as the users wish
//
do {
//
// Nested multiway if to determine the winner and update the score
//
cout << "Player 1 please press p for paper, s for scissor and r for rock.n";
cin >> play1Choice;
cout << "Player 2 please press p for paper, s for scissor and r for rock.n";
cin >> play2Choice;
if ((play1Choice == 'P')||(play1Choice == 'p'))
if ((play2Choice == 'P')||(play2Choice == 'p'))
{
cout << "Nobody wins.n";
cout << "Do you want to play again?: ";
cin >> playAgain;
}
else if ((play2Choice == 'S')||(play2Choice == 's'))
{
cout << "Player 2 wins. Scissors cut paper.n";
cout << "Do you want to play again?: ";
cin >> playAgain;
}
else
{
cout << "Player 1 wins. Paper covers rock.n";
cout << "Do you wan to play again?: ";
cin >> playAgain;
}
else if ((play1Choice == 'R')||(play1Choice == 'r'))
if ((play2Choice == 'R')||(play2Choice == 'r'))
{
cout << "Nobody wins.n";
cout << "Do you want to play again?: ";
cin >> playAgain;
}
else if ((play2Choice == 'P')||(play2Choice == 'p'))
{
cout << "Player 2 wins. Paper covers rock. n";
cout << "Do you want to play again?: ";
cin >> playAgain;
}
else
{
cout << "Player 1 wins. Rock breaks scissors.n";
cout << "Do you want to play again?: ";
cin >> playAgain;
}
else if ((play1Choice == 'S')||(play1Choice == 's'))
if ((play2Choice == 'S')||(play2Choice == 's'))
{
cout << "Nobody wins.n";
cout << "Do you want to play again?: ";
cin >> playAgain;
}
else if ((play2Choice == 'R')||(play2Choice == 'r'))
{
cout << "Player 2 wins. Rock breaks scissor.n";
cout << "Do you want to play again?: ";
cin >> playAgain;
}
else
{
cout << "Player 1 wins. Scissors cut paper.n";
cout << "Do you want to play again?: ";
cin >> playAgain;
}
}
while (playAgain == 'Y' || playAgain == 'y');
system("PAUSE");
return EXIT_SUCCESS;
}
void printWelcome()
{
cout << endl << endl;
cout << "Welcome to the Paper, Rock, Scissors Game!!!" << endl;
cout << "============================================" << endl;
cout << endl;
cout << "At each turn, both players enter a letter indicating";
cout << " their choice - " << endl;
cout << "P or p denotes Paper, R or r denotes Rock, S or s denotes Scissors."
<< endl << endl;
cout << "Start playing ... " << endl << endl;
}
char CheckUserInput(char charUserInput)
{
return(toupper(charUserInput)!='P'||'R'||'S')
return false;
else
return true;
}
Attachment:- Paper.zip
Relationship between price and quantity demanded
: The law of supply states that there is a direct relationship between price and quantity demanded. In the circular flow model, firms own economic resources, and householdsbuy the manufactured products and services
|
Why do systems analysts build models
: How do they choose what to model, and which modeling techniques to use.
|
How many students do you expect will be unable to complete
: Assume that the class has 60 students and that the examination period is 90 minutes in length. How many students do you expect will be unable to complete the exam in the allotted time?
|
Analyze the business environment and competition
: Research Brief- Pick a company (Part 1) "Strategy means making clear-cut choices about how to compete. You cannot be everything to everybody, no matter what the size of your business or how deep its pockets." Jack Welch For this assignment you wil..
|
Program simulates the game of paper, rock, scissors
: This program simulates the game of paper, rock, scissors. At each turn each player enters R, P, or S (either upper or lower case) to indicate their choice. The program announces the winner along with a message indicating the reason (such as Paper cov..
|
What is the advantage of using the normal probability
: What is the advantage of using the normal probability distribution to approximate the binomial probabilities? Use part
|
Business brief that details your recommendation
: Risk analysis is an essential practice in all business environments. What are the implications of option 1 versus option 2? Or even options 3, 4, and 5?! The key to risk analysis is to identify factors that have possible impact and assign a risk v..
|
Calculate the cost base of the land
: Advise Alex whether the amount of $650,000 is ordinary income, assessable under s6-5 or whether any amount is assessable under s15-15 - calculate the cost base of (a) the land and (b) the house for Capital Gains Tax purposes. Explain what amounts a..
|
Sum of regenarate efficiency
: Assume compressor and turbine efficiencies of 80% and 85%. A) find nth, T4a? B) what is nth if sum of regenarate efficiency is 80% installed?
|