In: Computer Science
Write a C++ program to score the paper-rock-scissor game. Each of two players (player1 and player2) input a character which could be either ‘P’, ‘R’, or ‘S’ (in uppercase or lowercase). For any other input character should display a message “Invalid input”. The program then announces who is the winner as well as the basis for determining the winner which could be one of the following: “Paper covers rock”, “Rock breaks scissors”, “Scissors cut paper”, or “Nobody wins”. (Use switch statement)
Please do not add up the scores just have a simple quick game and then I would have to reset the program to play again
#include <iostream>
#include <string>
#include <cstdlib>      //rand()
#include <ctime>        //time()
using namespace std;
int main(){
  
  int randNumber;
  string input, rock, paper, scissor;
  
  cin >> input;
    
    if(input=="rock"||input=="paper"||input=="scissor"){
        
        cout << "Type in: rock, paper or scissor:\n" <<endl;
        cout << " " << endl;
        
        //Random number by help of time
        srand( unsigned (time(0)));            
  
        //random number betw 1 & 3
        randNumber=rand()%3+1;      
        
        if(input == "rock"){   
            
            switch (randNumber){    
                case 1:
                cout<<"rock vs rock\n"<<endl;
                cout<<"*****DRAW*****";
                break;
        
                case 2:
                cout<<"rock vs paper\n"<<endl;
                cout<<"*****You LOSE*****"; 
                break;
        
                case 3:
                cout<<"rock vs scissor\n"<<endl;
                cout<<"*****You WON*****";
                break;
            }
        }
        
        else if(input == "paper"){
            
             switch (randNumber){
                case 1:
                cout<<"paper vs paper\n"<<endl;
                cout<<"*****DRAW*****";
                break;
                
                case 2:
                cout<<"paper vs scissor\n"<<endl;
                cout<<"*****You LOSE*****";
                break;
                
                case 3:
                cout<<"paper vs rock\n"<<endl;
                cout<<"*****You WON*****";
                
            }
        }
        
        else if(input == "scissor"){
            
            switch(randNumber){
                case 1:
                cout<<"scissor vs scissor\n"<<endl;
                cout<<"*****It's a DRAW*****";
                break;
                
                case 2:
                cout<<"scissor vs rock\n"<<endl;
                cout<<"*****You LOSE*****";
                break;
                
                case 3:
                cout<<"scissor vs paper\n"<<endl;
                cout<<"*****You WON*****";
                break;
            }
        }
    }   
   
    else{
        cout<<"You typed:    "<<input<<endl;
        cout<<" "<<endl;
        cout<<"That's not correct.\n"<<endl;
        cout<<"Type in; rock, paper or scissor.";
    }
    
    return 0;
}