Question

In: Computer Science

PROGRAMING in C RPSLS: The program that we must implement must allow two players to play...

PROGRAMING in C RPSLS:

The program that we must implement must allow two players to play in the same console (there will be only one program)
The program will initialize the information necessary to be able to store the name of two players and their respective markers throughout the game, to present
a result message at the end of the game.

1. When the program is ready for the game to start, it will ask PLAYER1 enter your name.
2. It will then ask PLAYER2 to enter their name.

As long as the game is not over (that is, until one of the two players arrives to 3 points) the program:
• Will ask PLAYER1 to place his bet (can be entered in the form of numeric code, or in the form of a character string)
• Will ask PLAYER2 to place his bet (similarly)
• Evaluate both bets, and modify the markers of each of the two players based on bets
• When either of the two players reaches the score of 3 points, it will be over the game

3. Message will be displayed on the screen that says: "PLAYER NAME1 has won PLAYERNAME2: SCOREBOARD "if PLAYER1 has won, where SCORE will be the result of the game (for example 3-2).

Then it will say "PLAYERNAME2 has lost against PLAYER NAME1: MARKER "because then PLAYER2 will have lost, and MARKER will have the result reversed (for example 2-3). If he player who has won is PLAYER2, the messages will indicate the victory of the PLAYER2 and PLAYER1's defeat.

As soon as the above message is presented, the program will end the program must NOT have any input parameters at the time of making
the program call, and all the parameters you might need (names and bets) will be entered by keyboard (upon presentation of a message that clearly state what the user is expected to key in (such as,say your NAME, enter your BET, etc.)

Solutions

Expert Solution

#include<stdio.h>
#include<conio.h>
void main()
{
char player1[10],player2[10];
int in1,in2;
printf("HELLO, WELCOME TO ROCK, PAPER, SCISSORS GAME\nWhat is player1's name?\n ");
scanf("%s",&player1);
printf("What is player2's name?\n ");
scanf("%s",&player2);

printf("%s and %s please follow the rules for the game\nPress 1 for stone\nPress 2 for paper\nPress 3 for scissors\n\n",player1,player2);
printf("Now let us start the game\n");

printf("%s is it STONE 1, PAPER 2 OR SCISSORS 3\n",player1);
scanf("%d",&in1);
printf("%s is it STONE 1, PAPER 2 OR SCISSORS 3\n",player2);
scanf("%d",&in2);

if ((in1==1 && in2==1) || (in1==2 && in2==2) || (in1==3 && in2==3))
printf("Neither %s nor %s won, it is a draw",player1,player2);

else if ((in1==1 && in2==3) || (in1==3 && in2==2) || (in1==1 && in2==3)|| (in1==2 && in2==1) || (in1==3 && in2==2) || (in1==1 && in2==3))
printf("Congrats %s! You won!!!!",player1);

else if ((in1==1 && in2==2) || (in1==3 && in2==1) || (in1==1 && in2==2)|| (in1==2 && in2==3))
printf("Congrats %s! You won!!!!",player2);

}

OUTPUT:

HELLO, WELCOME TO ROCK, PAPER, SCISSORS GAME
What is player1's name?
Alex
What is player2's name?
John
Alex and John please follow the rules for the game
Press 1 for stone
Press 2 for paper
Press 3 for scissors

Now let us start the game
Alex is it STONE 1, PAPER 2 OR SCISSORS 3
1
John is it STONE 1, PAPER 2 OR SCISSORS 3
2
Congrats John! You won!!!!


Related Solutions

Design and implement a Python program which will allow two players to play the game of...
Design and implement a Python program which will allow two players to play the game of Tic-Tac-Toe in a 4x4 grid! X | O | X | O -------------- O | O | X | O -------------- X | X | O | X -------------- X | X | O | X The rules for this game is the same as the classic, 3x3, game – Each cell can hold one of the following three strings: "X", "O", or "...
I am using C++ Write a program that allows two players to play a game of...
I am using C++ Write a program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that does the following: Displays the contents of the board array. Allows player 1 to select a location on the board for an X. The program should ask the user...
C++ PROGRAMING Implement a program to evaluate simple mathematical expressions. Assume that the original expression is...
C++ PROGRAMING Implement a program to evaluate simple mathematical expressions. Assume that the original expression is provided to the program as a text string. Allowed expression tokens: brackets “(” and “)”, integers like “4”, “15”, addition “+”, subtraction “-”, multiplication “*”, division “/”. Output can be float. Trim spaces from an expression. Brackets should contain at least one operation. Make sure that an expression is validated before it is calculated; reject the invalid expressions with appropriate message. The program must...
C program with functions Make a dice game with the following characteristics: must be two players...
C program with functions Make a dice game with the following characteristics: must be two players with two dice. when player 1 rolls the marker is annotated when player 2 rolls the marker is annotated in other words, for each roll the added scores must be shown. Example: Round 1: player 1 score = 6 player 2 score = 8 Round 2: player 1 score = 14 player 2 score = 20 Whoever reaches 35 points first wins. if a...
how to implement h / k sqrt (n) in c programing
how to implement h / k sqrt (n) in c programing
MUST BE DONE IN C (NOT C++) Your create a program that can implement the cases...
MUST BE DONE IN C (NOT C++) Your create a program that can implement the cases in which the initial unit is Fahrenheit or something not recognizable. Your program should incorporate Fahrenheit to Celsius, Fahrenheit to Kelvin and unknown initial units (display an error message for this last one). You must use functions to calculate Fahrenheit degrees.
MUST BE DONE IN C (NOT C++) In this program we will calculate the average of...
MUST BE DONE IN C (NOT C++) In this program we will calculate the average of x students’ grades (grades will be stored in an array). To do so, please follow these guidelines: - Your program should ask the user for the number of students that are in the class. This number should help you declare your array. - Use the function seen in class to scan the grades of the array. In other words, we will populate the array...
IN C++ Write a program to play the Card Guessing Game. Your program must give the...
IN C++ Write a program to play the Card Guessing Game. Your program must give the user the following choices: - Guess only the face value of the card. -Guess only the suit of the card. -Guess both the face value and suit of the card. Before the start of the game, create a deck of cards. Before each guess, use the function random_shuffle to randomly shuffle the deck.
java programing project Implement a program that computes the Fibonacci of a specified number, the factorial...
java programing project Implement a program that computes the Fibonacci of a specified number, the factorial of a specified number, or estimates the value of 'e' using the specified number of iterations (of a Taylor series). Please feel free to use the Internet to find resources that explain how to estimate the value of 'e' using a Taylor series. In the case of no or invalid number of parameters, the program should show help instructions that looks like: --- Assign...
Write a program that allows two players to play a game of tic-tac-toe. Use a two-dimensional...
Write a program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that does the following: Displays the contents of the board array. Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT