Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would I code this in C programming? NOT C++ Just C programming. Also, if possible, I would appreciate a screenshot of the code with

How would I code this in C programming? NOT C++ Just C programming. Also, if possible, I would appreciate a screenshot of the code with how it looks compiled to make things easier. I just need to the last 5 steps and provided the code for the 1st step. Thank you.

image text in transcribed

#include

#include

#include

#include

int ComputerMove(){

srand(time(NULL));

int randNum = (rand() % 3) + 1;

return randNum;

}

int UserMove(){

int num1;

scanf("%d",&num1);

return num1;

}

int main(){

int computerMove;

computerMove=ComputerMove();

printf("Computer Chose %d ",ComputerMove());

printf("User Chose %d ",UserMove());

int userMove;

userMove=UserMove();

//printf("%d ",userMove);

//printf("%d ",computerMove);

printf("computer chose ");

if(computerMove==1)

{

printf("Rock! ");

}

else if(computerMove==2)

{

printf("Paper! ");

}

else if(computerMove==3)

{

printf("Scissor! ");

}

else printf("Tie!");

//{

if ((userMove==1)&&(computerMove==1))

{

printf(" Tie!");

}

else if ((userMove==1)&&(computerMove==2))

{ printf(" Computer Wins!");

}

else if ((userMove==1)&&(computerMove==3))

{ printf(" User Wins!");

}

else if((userMove==2)&&(computerMove==1))

{ printf(" User Wins!");

}

else if((userMove==2)&&(computerMove==2))

{ printf(" Tie!");

}

else if((userMove==2)&&(computerMove==3))

{ printf(" Computer Wins!");

}

else if((userMove==3)&&(computerMove==1))

{ printf(" Computer Wins!");

}

else if((userMove==3)&&(computerMove==2))

{ printf(" User Wins!");

}

else if((userMove==3)&&(computerMove==3))

{ printf(" Tie!");

}

else

{ printf("You have select an invalid selection.");

}

}

Goals The goals for you to accomplish during class today are as follows: 1. Practice modular design! Write a function that plays rock, paper, or scissors with the user Start with the code you wrote that provides a ComputerMove function that picks the Rock, Paper, Scissors move randomly for the computer player, and a UserMove function that asks the user for their move and returns their selection Move the two function calls and the winner decision logic into a self-contained function called RockPaperScissors which plays one round of the game and returns the winner (0-tie, 1 user won, 2 computer won In your main(), call the RockPaperScissors function to play one round If the players tied, call the RockPaperScissors function again to play again Repeat until someone wins Make sure your code compiles and runs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

Explain the different types of marketing strategies.

Answered: 1 week ago

Question

Explain product positioning.

Answered: 1 week ago

Question

Explain Industrial market segment.

Answered: 1 week ago