Answer to Question #14923 in C++ for Darryl kaye Sanga

Question #14923
Write a program to score the paper - rock - scissor game. Each of two users types in 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. Your program should include a loop that lets the user play again until user says she or he is done.
1
Expert's answer
2012-09-14T10:47:21-0400

#include <conio.h>
#include <iostream>
using namespace std;

int main(){
& char z1,z2;


while (z1!='q' && z2!='q' ){

cout<<"User 1: ";
& cin>>z1;
& cout<<"User 2: ";
& cin>>z2;
& //p s r
&
if (z1=='p' || z1=='P' ){
& if (z2=='s' || z2=='S' )
cout<<"Defeated user 2\n";
else if (z2=='r' || z2=='R' )
cout<<"Defeated user 1\n";
else& if (z2=='P' || z2=='p' )
cout<<"nobody wins";
else
& cout<<"Error\n"; & }

else& if& (z1=='r' || z1=='R'){
& if (z2=='s' || z2=='S' )
cout<<"Defeated user 1\n";
else& if (z2=='r' || z2=='R' )
cout<<"nobody wins\n";
else& if (z2=='P' || z2=='p' )
cout<<"Defeated user 1";
else
& cout<<"Error\n";
}
&
else if& (z1=='s'& || z1=='S'){
& if (z2=='r' || z2=='R' )
cout<<"Defeated user 1\n";
& else if (z2=='P' || z2=='p' )
cout<<"nobody wins\n";
& else if (z2=='s' || z2=='S' )
cout<<"Defeated user 1";
else
& cout<<"Error\n";
& }
& else
& cout<<"Error\n";
&
cout<<"Enter 'q' to exit\n";

&
}
}
&

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS