Answer to Question #245060 in C++ for TURBO C++

Question #245060

Program that will simulate the Paper, Rock, Scissors game. Two players should be able to either P, R or S then the program shall determine who the winner is and state why he wins based on the following criteria


Paper covers Rock

Scissor cut paper

Rock breaks scissors



***Sample Output***

PAPER ROCK SCISSORS GAME

Player 1: P Player 2: S


Player 2 wins. Scissors cut Paper



please use ,

#include<stdio.h>

#include<conio.h>


scanf:

printf


1
Expert's answer
2021-09-30T15:55:51-0400
#include <stdio.h>
#include <conio.h>


int main()
{
    printf("PAPER ROCK SCISSORS GAME\n");


    printf("Enter choice for Player 1(P,R, or S): ");
    char choiceOfFirstPlayer;
    scanf(" %c", &choiceOfFirstPlayer);


    printf("Enter choice for Player 2(P,R, or S): ");
    char choiceOfSecondPlayer;
    scanf(" %c", &choiceOfSecondPlayer);


    printf("\n");


    printf("Player 1: %c Player 2: %c \n",choiceOfFirstPlayer, choiceOfSecondPlayer);


    if(choiceOfFirstPlayer != choiceOfSecondPlayer)
    {
        if(choiceOfFirstPlayer == 'P')
        {
            if(choiceOfSecondPlayer == 'R')
                printf("Player 1 wins. Paper covers Rock");
            else
                printf("Player 2 wins. Scissors cut Paper");
        }
        else if(choiceOfFirstPlayer == 'R')
        {
            if(choiceOfSecondPlayer == 'P')
                printf("Player 2 wins. Paper covers Rock");
            else
                printf("Player 1 wins. Rock breaks Scissors");
        }
        else
        {
            if(choiceOfSecondPlayer == 'R')
                printf("Player 2 wins. Rock breaks Scissors");
            else
                printf("Player 1 wins. Scissors cut Paper");
        }
    }


    printf("\n\n");
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Xtian
01.10.21, 11:33

Who ever code this. You’re awesome. Thank You for your help. God bless

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS