Write a program to score the paper-rock-scissor game. Each of two users types in either P, R, or S. The program then announces the winner as well as the basis for determining the winner: Paper covers rock, Rock breaks scissors, Scissors cut paper, or Nobody wins. Be sure to allow the users to use lowercase as well as uppercase letters.
//System Libraries
#include <iostream> //Input/Output Library
#include <iomanip>
#include <string>
using namespace std;
//User Libraries
//Global Constants, no Global Variables are allowed
//Math/Physics/Conversions/Higher Dimensions - i.e. PI, e, etc...
//Function Prototypes
//Execution Begins Here!
int main(int argc, char** argv) {
//Set the random number seed
//Declare Variables
float
P,p,
R,r,
S,s,
p1,p2;
//Initialize or input i.e. set variable values
cout<<"Rock Paper Scissors Game\n";
cout<<"Input Player 1 and Player 2 Choices\n";
cin>>p1;
cin>>p2;
//Map inputs -> outputs
if (p1 == p2)
cout<<"tie";
if ((p1 == P) && (p2 == R))
cout<<"Paper covers rock.";
if ((p1 == p) && (p2 == r))
cout<<"Paper covers rock.";
if ((p1 == P) && (p2 == r))
cout<<"Paper covers rock.";
if ((p1 == p) && (p2 == R))
cout<<"Paper covers rock.";
if ((p1 == S) && (p2 == R))
cout<<"Rock breaks scissors.";
if ((p1 == s) && (p2 == r))
cout<<"Rock breaks scissors.";
if ((p1 == S) && (p2 == r))
cout<<"Rock breaks scissors.";
if ((p1 == s) && (p2 == R))
cout<<"Rock breaks scissors.";
if ((p1 == S) && (p2 == P))
cout<<"Scissors cut paper.";
if ((p1 == s) && (p2 == p))
cout<<"Scissors cut paper.";
if ((p1 == S) && (p2 == p))
cout<<"Scissors cut paper.";
if ((p1 == s) && (p2 == P))
cout<<"Scissors cut paper.";
//Display the outputs
//Exit stage right or left!
return 0;
}
Expected:
Rock Paper Scissors Game
Input Player 1 and Player 2 Choices
Paper covers rock
MY RESULTS:
Rock Paper Scissors Game
Input Player 1 and Player 2 Choices
rs
tiePaper covers rock.Paper covers rock.Paper covers rock.Paper covers rock.Rock breaks scissors.Rock breaks scissors.Rock breaks scissors.Rock breaks scissors.Scissors cut paper.Scissors cut paper.Scissors cut paper.Scissors cut paper.