Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

• Create a user player and a computer competitor. • Ask the user for number of g

ID: 3626059 • Letter: #

Question

• Create a user player and a computer competitor.
• Ask the user for number of games. Number must be odd. If even, make number one more than what was entered. Print games needed to win.
o Example: Best of 5 means 3 wins are needed to win.
• User selects a weapon as a string.
• After the user selects a weapon, the computer draws an object at random.
• Chooses a winner based on standard RPS rules.
• Keep running tallies of wins, losses and ties for each player, as well as how many times each object is chosen by either player.
• Ties should not count as a game.
o Example: In a best of 5, it is possible to end with 3 wins, 2 losses, and 3 ties.
• Choose an overall winner. Display the tally of objects chosen.
• Your program must use functions to do all of this.

Expected output [input in bold]
Enter the number of matches.
5
Player 1, choose an object.
Scissors

Player 2 has selected Rock.

Rock breaks Scissors.
You win!

Rock chosen 1 time(s) Paper chosen 0 time(s) Scissors chosen 1 time(s) (Repeat after every match, must be running tally.)

(Do for best of 3, as above).

Player 1 wins the match.

Player 1 – 2 win(s), 1 loss(es), 1 tie(s).
Player 2 – 1 win(s), 2 loss(es), 1 tie(s).


Player 1 is the RPS Champion.

I have this so far: I need help with creating the string.
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

// Number of games.
int games(int);

//Choosing an object:string .






int main(void)

{
int you



printf("This is rock paper scissors. ");
printf("Lets start by choosing number of games.");
printf("You must enter the number of matches, preferably an odd number of matches between you and the computer.");
scanf(%d,&you);
int games(you);






}

//declaring functions
int games(int number)
{

a=number
int a;
int b;
int c;
int d;
b = 2;

c = a % b;

if (c == 0)
{
printf("You have entered: %d. It is even number of games. ", a);
d=a+1
}
else
{
printf("You have entered: %d. It is odd off number of games. ", a);
d=a
}

printf("your going to play is %d games! And you need to win approximately half of the games to win (%d). ", a,d);

return(0);
}

Explanation / Answer

please rate - thanks

try this

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

int computer();
int user();
void printtally(int,int,int,int[]);
void score(int ,int,int*,int*,int*);
int intro();
int main()
{int games;

int c=0,p=0,t=0,tally[3]={0,0,0},i;
games=intro();
srand(time(0));
int usermove;
int computermove;
for(i=0;i<games;i++)
   { usermove=user();
     computermove=computer();
     tally[usermove]++;
     tally[computermove]++;
     score(usermove,computermove,&c,&p,&t);
     printtally(c,p,t,tally);
     }
   if(c>p)
       printf("Player 1 is the RPS Champion. Cue Queen music. ");
   else if(p>c)
       printf("Player 2 is the RPS Champion. Cue Queen music. ");
   else
       printf("It's a tie for the RPS Champion. Cue Queen music. ");
   getch();
return 0;
}
int intro()
{int games;
char ch;
printf("This is rock paper scissors. ");
printf("Lets start by choosing number of games.");
printf("You must enter the number of matches, preferably an odd number of matches between you and the computer. ");
printf("enter number of games to play: ");
scanf("%d",&games);
if(games%2==0)
    {printf("You have entered: %d. It is even number of games. ", games);
     ++games;
     }
     printf("your going to play %d games! And you need to win approximately half of the games to win (%d). ", games,games/2+1);
    while ((ch = getchar()) != ' ' );
}
void printtally(int c,int p,int t,int tally[])
{
printf("Player 1 - %d win(s), %d loss(es), %d tie(s). ",c,p,t);
printf("Player 2 - %d win(s), %d loss(es), %d tie(s). ",p,c,t);
printf("Rock chosen %d time(s) Paper chosen %d time(s) Scissors chosen %d time(s) ",
tally[0],tally[1],tally[2]);
}

int user()
{char ch;
int move;
char a[8];
char moves[3][9]={"rock","paper","scissors"};
do{
    printf("Choose your weapon (rock,paper,scissor): ");
    scanf("%s",&a);
    for(move=0;move<3;move++)
     if (strncmp (moves[move],a,strlen(a)) == 0)
           return move;
     printf("invalid entry ");
    }while(move==3);
}

int computer()
{char moves[3][9]={"rock","paper","scissors"};
int move=rand()%3;
printf("Player 2 has selected %s ",moves[move]);
return move ;
}

void score(int user,int computer,int *c,int *p,int *t )
{
if(user==computer)
    {printf("Tie! ");
    *t=*t+1;
    }
else if(user==0&&computer==2)
    { printf("You break my sissors. you win! ");
    *p=*p+1;
    }
else if(user==0&&computer==1)
     {printf("I cover your rock. you lose! ");
     *c=*c+1;
     }
else if(user==1&&computer==2)
     {printf("I cut your paper. you lose! ");
     *c=*c+1;
     }
else if(user==1&&computer==0)
      {printf("You cover my rock. you win! ");
      *p=*p+1;
    }
else if(user==2&&computer==0)
      {printf("I break your sissors, you lose! ");
       *c=*c+1;
      }
else
       {printf("You cut my paper. you win! ");
       *p=*p+1;
       }
}