Sunday, June 7, 2020

Paper-Rock and Scissor Game in C

A game called Paper-Rock and Scissors written and given to us by my friend and fellow software engineer Sir Ernel. Thank you so much Sir Ernel.

I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.My mobile number here in the Philippines is 09173084360. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price. My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.comI am also a book author you can purchase my books on computer programming and information technology in the following links below.https://www.unlimitedbooksph.com/

Program Listing


/* Paper-Rock and Scissor Game in C */
#include <stdio.h>
int main ()
{
char p1, p2;
printf("\n       Welcome to Rock-Paper-Scissor Game\n");
printf("\nInstructions: \n Enter [r]rock [p]paper [s]scissor \n");
printf ("\n Enter Player 1: ");
do{
scanf("%c",&p1);
if(p1!='p' && p1!='P' && p1!='s' && p1!='S' && p1!='r' && p1!='R')
{
if(p1!='\n')
printf("\a\nInvalid character %c \nPlease enter valid character r,p,s only\n",p1);
}
}
while(p1!='p' && p1!='P' && p1!='s' && p1!='S' && p1!='r' && p1!='R');
printf ("\n Enter Player 2: ");
do {
scanf("%c",&p2);
if(p2!='p' && p2!='P' && p2!='s' && p2!='S' && p2!='r' && p2!='R') {
if(p2!='\n')
printf("\a\nInvalid character %c \nPlease enter valid character r,p,s only\n",p2);
}
}
while(p2!='p' && p2!='P' && p2!='s' && p2!='S' && p2!='r' && p2!='R');
if (((p1=='p')||(p1=='P')) && ((p2=='R') || (p2=='r'))) {
printf ("\n Player 1 Wins !");
printf ("\n Paper Covers Rock");
}
else 
if (((p2=='p') || (p2=='P')) && ((p1=='r') || (p1=='R'))) {
printf ("\n Player 2 Wins !");
printf ("\n Paper Covers Rock");
}
else 
if (((p1=='r') || (p1=='R')) && ((p2=='s') || (p2=='S'))) {
printf ("\n Player 1 Wins !");
printf ("\n Rock Breaks Scissors");
}
else 
if (((p2=='r') || (p2=='R')) && ((p1=='s') || (p1=='S'))) {
printf ("\n Player 2 Wins !");
printf ("\n Rock Breaks Scissors");
}
else 
if (((p1=='s') || (p1=='S')) && ((p2=='p') || (p2=='P'))) {
printf ("\n Player 1 Wins !");
printf ("\n Scissors Cut Paper");
}
else 
if (((p2=='s') || (p2=='S')) && ((p1=='p') || (p1=='P'))) {
printf ("Player 2 Wins !");
printf ("Scissors Cut Paper");
}
else 
if (p1==p2) {
printf ("\n Nobody Wins !");
printf ("\n Both Of You Entered The Same Letters");
}
return 0;
}

No comments:

Post a Comment