Free Essay

Rock Paper and Scissors

In:

Submitted By cjaranza
Words 282
Pages 2
ROCK, PAPER AND SCISSORS

include <iostream>
#include <iomanip>
#include <string>

using namespace std;

char userinput; int wincount, gamescount;

enum objtype { rock, paper, scissor}; objtype playerobject, cpuobject;

objtype playerselection (char playerinput); objtype cpuselection();

string show_obj_player, show_obj_computer;

void winner();

int main(){

char resp;

do{ cout << "Choose rock (r), paper (p) or scissor (s)" << endl; cin >> userinput;

winner(); cout << endl << "Player --> " << show_obj_player << " Cpu --> " << show_obj_computer << endl<<endl;

cout << "Do you want to try again?"; cin >> resp;

} while (resp == 'y');

system("pause");
}

objtype playerselection(char playerinput){ if (playerinput == 'r'){ playerobject = rock; show_obj_player = "rock"; return playerobject; } else if (playerinput == 'p'){ playerobject = paper; show_obj_player = "paper"; return playerobject; } else playerobject = scissor; show_obj_player = "rock"; return playerobject;
}

objtype cpuselection(){ int numrand;

srand(time(NULL)); numrand = 0 + rand() % ((2 + 1) - 0);

if (numrand == 0){ cpuobject = rock; show_obj_computer = "rock"; return cpuobject; } else if (numrand == 1){ cpuobject = paper; show_obj_computer = "paper"; return cpuobject; } else{ cpuobject = scissor; show_obj_computer = "scissor"; return cpuobject; }

};

void winner(){ objtype player, computer;

player = playerselection(userinput); computer = cpuselection();

if (player == computer) cout << "Draw"; else if (player == rock && computer == scissor) cout << "You win"; else if (player== rock && computer == paper) cout << "You loose"; else if (player == paper && computer == rock) cout << "You win"; else if (player == paper && computer == scissor) cout << "You loose"; else if (player == scissor && computer == paper) cout << "You win"; else if (player == scissor && computer == rock) cout << "You loose"; else cout << "Your selection is invalid";
}

Similar Documents

Premium Essay

Microsoft Case Study

...I.TITLE CHOPSTICK ( HAND GAME ) II.GOAL The goal of the game is for a player to force their opponent to extend all of their fingers and thumbs on both hands. III.OBJECTIVES At the end of the activity the players would be able to : 1. develop their mathematical ability 2. use their agility skills IV.PARTICIPANTS YOUTHS V.INSTRUCTION Each player uses both hands to play the game, the number of digits extended on a hand showing the number of points that the hand has. Both players start with each hand having one point — one finger extended on each hand. The goal of the game is for a player to force their opponent to extend all of their fingers and thumbs on both hands. A hand with all fingers and its thumb extended is said to be a "dead hand". Players take turns to tap one of their hands against another hand that is not dead (either their own other hand, or one of their opponent's). The number of points on the tapping hand is added to the number on the tapped hand, and the player with the tapped hand should extend their digits to show the new score. The tapping hand remains unchanged. A player may tap their own hand to transfer points from one hand to the other. For example, if a player had three points on his or her right hand and one on his or her left, the player could rearrange them to have two on each hand. A "dead hand" is treated as having no points, for this purpose, which allows a player to bring a dead hand back into play by transferring points to...

Words: 1395 - Pages: 6

Premium Essay

Why Do Rock Paper Scissors Win More Than Playing

...Problem Can a science based strategy for the game rock, paper, scissors win more than playing randomly? It is important to understand because the game is used to settle arguments and choices between two things. I wanted to confirm through experimentation that people do not play the game randomly, they use patterns and tendencies that an opponent can take advantage of. Hypothesis A science based approach when playing rock paper scissors will win more games than playing randomly. Experiment For my experiment, I am going to play 100 games of wins or losses of rock, paper, scissors using science based strategies against humans and 100 games of wins and losses against random computer selections. I did not record the ties, only wins and losses. The...

Words: 407 - Pages: 2

Free Essay

Prg 410 Week 3 Assignment

...Ask input range is between (1-100) player will win with 10 points for one value. • Ask input range is between (101-200) player will win with 20 points for one value. • Ask input range is between (201-500) player will win with 50 points for one value. Add all five values for HERO/HEROs and printout the winner of the game. Problem 2: Rock, Paper, Scissors Game [marks 20] Write a program that lets the user play the game of Rock, Paper, and Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the computers choice yet) 2. The user enters his or her choice of rock, paper, or scissors at the key-board. (Use a menu) 3. The computers choice is displayed. 4. A winner is selected according to the following rules: • If one player chooses rock and the other player chooses scissors, then rockwins. (The rock smashes the scissors.) • If one player chooses scissors and the other player chooses...

Words: 933 - Pages: 4

Premium Essay

Positive Reinforcement Strategies

...It is important for physical education teachers to manage and discipline their class effectively and acceptably. One of my favorite positive reinforcement strategies is implementing activity reinforcers. Activity reinforcers are activities that the children enjoy that are awarded because of good behavior. Examples would include free time, playing a game, student of the day, being a teacher’s aide, extra time in physical education class, etc. (Pangrazi, 2016). I prefer this strategy because it incorporates physical activity as a reward. A good method I learned in PED-415 for resolve conflicts between students is rock-paper-scissors. This can be used in disagreements between students for just about anything. It is especially good when students...

Words: 389 - Pages: 2

Premium Essay

Kpmg

...in her own name and maintains a credit balance FAN NOTES: in this scenario, O+C=S, C=B+F, or O+B+F=S The events C and B are not mutually exclusive. The events O and F are not exhaustive. The events O and C are mutually exclusive. The events B and F are exhaustive. Event B is a simple event. A simple event is an individual outcome of a sample space. For this particular experiment, outcomes O, F, and B are simple events. The set S={O,C,B} is not the correct description of the sample space for the random experiment because the events in S are not mutually exclusive. P(F)=0.21 P(C)=0.29 P(B)=0.08 Question 3: Scenario: rock-paper-sissor game The probabilities are assigned using the subjective approach. Suppose that flat mate B’s probability assignments are correct. What can you say about P(SA), and probability that flat mate A choose scissors? P(SA)=0.06 0<=P(SA)<=1 Assume that flat mate B’s probability...

Words: 908 - Pages: 4

Premium Essay

Micro Boom As Seen On Tv Rhetorical Analysis

...State of the art rhetoric? Infomercials today are found on every channel on television and cable here in the United States; these effective ads are made to persuade a wide audience to buy their product and are displayed throughout the day. These ad companies use various powerful elements of rhetoric; Logos, the use of logic to support a claim; Ethos, the use of authority/credibility and Pathos, the usage of emotional appeal. Like a game of rock, paper, scissors each and every element has its strengths and weaknesses and to effectively persuade the audience each element must be equal, and not overpower one another. From a list of ads, I found an ad titled “Micro Boom as Seen on TV” (https://www.youtube.com/watch?v=agcbsR8oFms). This infomercial...

Words: 1007 - Pages: 5

Premium Essay

Game Theory

...GAME THEORY & ASYMMETRIC INFORMATION LITERATURE REVIEW NATHALIA PALOMINO ID# 0501605 MARCH 1, 2014. FACILITATOR: SHELLEY WHITTLE Introduction This paper will firstly address game theory, Prisoners Dilemma which is a very prominent game and Bargaining. Asymmetric Information is also discussed along with a few examples of how asymmetric information relates to the business environment. The writer gives the reader a basic understanding of game theory and asymmetric information uses in a logical manner. As many opinions are combined to critically analyse the aforementioned. Game Theory A definition of Game Theory or something that appears to be a definition may be applied as such: An analytical or mathematical approach of examining strategic interaction when dealing with competitive situations in business decisions. As Keat, Young & Stephen (2014) did not give a clear definition of Game Theory. This definition stated business decision however, Martin (1978) stated that Game theory has proved useful in only war and economic. He states, “I see that at least three ways in which game theory has proved ‘useful’. First, it has led to practical advice on tactical decision-making in certain well defined situations, especially in military areas involving missile tracking and similar task (where the theory of differential games has led to results equivalent to control theory). Second, it has provided an occupation and amusement for thousands of government bureaucrats...

Words: 2354 - Pages: 10

Premium Essay

Pokemon's Journey-Personal Narrative

...After thinking about it for a while since I chose to head to Kanto, I've decided to go for Charmander. It's a fire-type, and I've always admired the beauty of fire. The way it dances, the way it changes color depending on what it burns. People say how fire is dangerous, but Fire is also a lifesaver. It brings warmth and life, just like water and nature. You know, I've actually always thought that the reason that fire, water, and grass -type pokemon are starters not because they are the main elements of the world, but for some other reason. Seriously, rock or ground is a main element too. It wouldn't be because of the perfect rock, paper, scissors representation either. I mean, you can replace water with rock and the circle would still be perfect. Rock beats fire, fire beats grass, and grass beats...

Words: 473 - Pages: 2

Free Essay

Discrete Maths

...21-110: Problem Solving in Recreational Mathematics Homework assignment 7 solutions Problem 1. An urn contains five red balls and three yellow balls. Two balls are drawn from the urn at random, without replacement. (a) In this scenario, what is the experiment? What is the sample space? (b) What is the probability that the first ball drawn is red? (c) What is the probability that at least one of the two balls drawn is red? (d) What is the (conditional) probability that the second ball drawn is red, given that the first ball drawn is red? Solution. (a) The experiment is the drawing of two balls from the urn without replacement. The sample space is the set of possible outcomes, of which there are four: drawing two red balls; drawing two yellow balls; drawing a red ball first, and then a yellow ball; and drawing a yellow ball first, and then a red ball. One way to denote the sample space is in set notation, abbreviating the colors red and yellow: sample space = {RR, YY, RY, YR}. Note that these four outcomes are not equally likely. We can also represent the experiment and the possible outcomes in a probability tree diagram, as shown below. Note in particular the probabilities given for the second ball. For example, if the first ball is red, then four out of the remaining seven balls are red, so the probability that the second ball is red is 4/7 (and the probability that it is yellow is 3/7). On the other hand, if the first ball is yellow, then five out of the remaining...

Words: 4161 - Pages: 17

Free Essay

Genuiz

...when converting degrees from Celsius to Fahrenheit, double the Celsius and add 28. on blahtherapy.com you can vent your problems to a complete stranger have hiccups? hold your breath and swallow 3 times. after making a bag of popcorn, open the bag slightly, flip it and shake out all the kernels. if you dont want your iphone to auto-rotate; double tap the home button, scroll left and hit the circle arrow button. to keep orange juice from tasting horrible after brushing your teeth, rinse with hot water. nest time you have a bad sore throat, eat marshmallows. storing batteries in the freezer can double their life span. looking for something? scan the room from right to left. your brain will pick up more because it’s not used to reading that way. if you’re ever being buried alive, take your shirt and tie it around your face and mouth to keep from suffocating. put your phone in a glass to make the speakers louder. get a mosquito bite?press a hot spoon on it. the heat from the spoon will kill the protein causing the itch.  to avoid having a double chin in photos put your tongue on the roof of your mouth. rub an ice cube on the v shape between your thumb and index finger to reduce toothache pain by 50% - find a random vending machine - enter code: 432112311 - immediately push and hold the coin return button - change will fall into the tray squirting salt water into the coin slot of a soda machine is said to cause an electrical current that will dispense free soda ABC’s...

Words: 554 - Pages: 3

Premium Essay

Rasel

...Page 1 of 7 Massachusetts Institute of Technology Department of Economics 14.01 Principles of Microeconomics Final Exam Wednesday, December 19th, 2007 Last Name (Please print): ______________ First Name: __________________ MIT ID Number: __________________ Instructions. Please read carefully. The exam has a total of 100 points. Answers should be as concise as possible. This is a closed book exam. You are not allowed to use notes, equation sheets, books or any other aids. You are not allowed to use calculators. You must write your answers in the space provided between questions. DO NOT attach additional sheets of paper. This exam consists of (18) sheets (13 pages + 5 blank pages for scratch work). 0. Circle Your Section/Recitation (1 point): Please circle the section or recitation which you are attending below. The marked exam will be returned to you, in the section or recitation that you indicate. You will loose 1 point if you leave it unselected. S01: MWF9 (Peter Schnabl) R01: F10 (Rongzhu Ke) S02: MWF10 (Chia-Hui Chen) R02: F11 (Rongzhu Ke) S03: MWF11 (Chia-Hui Chen) R03: F2 (Rongzhu Ke) S04: MWF1 (Monica Martinez-Bravo) R04: F12 (Marco Migueis) R05: F1 (Marco Migueis) R06: F2 (Marco Migueis) DO NOT WRITE IN THE AREA BELOW: Question 1 __/25 Question 2 __/5 Question 3 __/25 Question 4 __/25 Question 5 __/19 Question 0 _/1 Total __/100 Cite as: William Wheaton, Chia-Hui...

Words: 2239 - Pages: 9

Free Essay

People

...this research. The U.K., China, Russia, Australia, Netherlands and other countries are in the game. In the U.S., the CIA, National Security Agency and Pentagon are all funding research, while Los Alamos National Laboratory operates one of the most significant quantum computer labs. Negotiations to keep nuclear weapons from Iran are certainly critical, but if you play out the promise of quantum computing, an American machine could bust into Iranian systems and shut down all that country’s nuclear activity in an instant. It’s like a game of rock-paper-scissors: Nukes might be the world’s version of a rock, but quantum computers would be paper, winning every time. And yet, quantum computing research isn’t self-contained and secretive in the manner of the Los Alamos atomic bomb work during World War II. Some of it is academic work at universities such as the Massachusetts Institute of Technology, with findings shared in scientific papers. Technology companies are working on this, too, since these things have the potential to be business nukes. IBM, Google and Microsoft all fund research. Imagine if Google gets one before Microsoft. That pesky Bing could wind up vaporized. Google has a Quantum Artificial Intelligence unit working with the University of California, Santa Barbara, with a goal of developing a quantum machine that can learn. Meanwhile, a Canadian startup, D-Wave Systems, is partially funded by Amazon CEO Jeff Bezos—and the CIA. The very secretive and often controversial...

Words: 801 - Pages: 4

Free Essay

Http: //Www.Scribd.Com/Doc/24002413/%E2%80%9cthe-Effect-of-Study-Habits-on-the-Academic-Performance-of-Freshmen-Education-Students-in-Xavier-University-Cagayan-de-Oro-City-School-Year-2008-20

...clothing and or equipment.2. The teacher will check the level of the oil and gas in the lawn mower and fill accordingly. 3. The teacher will pull all weeds4. The teacher will start the mower5. The teacher will cut the grass6. The teacher will cut in opposing lines7. The teacher will mow in different directions to prevent graining8. the teacher will check the grass collector from time to time and if full, empty on suitable compost heap or garden dump9. The teacher will turn off the engine10. The teacher will place the mower back where it stored | * Grass cutting tools * Trimmer * Petrol brush cutter | ACTIVITY | TASK ANALYSIS | MATERIALS | Landscaping | 1. The teacher will draw a plan of yard2. The teacher will use gridded paper to help keep everything drawn to scale3. The teacher will call a local utility company and have them come out to show you where any ground power lines or water lines are4. The teacher will take overhead power lines into account5. the teacher will remind the student that planting shades trees...

Words: 1447 - Pages: 6

Free Essay

Social Media

...this song. She has appeared at the front of every single ever since.[citation needed] The group's 12th single, "Namida Surprise!", included voting tickets for the 2009 AKB48 Senbatsu Election, where fans can vote for who will be featured in the next single. Maeda won with 4,630 votes, becoming AKB48's most popular member and frontgirl for their 13th single, "Iiwake Maybe".[2] However, in 2010, another election was held and Maeda lost to Yuko Oshima, who had 31,448 votes, whereas Maeda had 30,851 votes, so Yuko became the frontgirl for "Heavy Rotation".[3] Later that year a different type of election was held (AKB48 Janken Senbatsu Tournament) where any member in the group could be front girl. The members were selected by using the rock-paper-scissors method and Mayumi Uchida received the top spot of AKB48's single "Chance no Junban" which marked the first time a relatively unknown member has been at the front of a single.[4] Maeda and Yuko were back at the front spots for the next single, "Beginner".[citation needed] In 2011, a third AKB48 senbatsu election was held. During the early results, Yuko Oshima was leading with first place. However in the final results Maeda won first place with 139,892 votes whereas Yuko Oshima had 122,843 votes beating her with 17,049 votes.[5] On 25 March 2012, during an AKB48 Concert at the Saitama Super Arena, Maeda announced that she would quit AKB48 soon.[6] Later, it was announced that Maeda would quit right after AKB48's Tokyo Dome 3-day concert...

Words: 352 - Pages: 2

Free Essay

It106 Assigments

...Contents Phase 1: Design Concepts 2 Project Description 2 Use Cases 3 Data Dictionary 4 High Level Design Components 5 Detailed Design: Checkout 7 Diagrams 7 Design Analysis 8 Detailed Design: Product Research 9 Diagrams 9 Design – Using Pseudocode 10 Product Profit 10 Phase 2: Sequential Logic Structures 11 Design 11 Product Profit 11 Phase 3: Problem Solving with Decisions 12 Safe Discount 12 Return Customer Bonus 13 Applying Discounts 14 Phase 4: Problem Solving with Loops 15 Total order 15 Problems to Solve 16 Calculate Profits 16 Rock, Paper, Scissors 18 Number Guessing Game 20 Phase 5: Using Abstractions in Design 22 Seeing Abstractions 22 Refactoring 22 Phase 1: Design Concepts Project Description Although we may be late to the game, we will nevertheless join the world of e-commerce to sell our fantastic product on the Internet. To do so, we need a Web site that will allow for commerce and sales. To be quick about it, we require the following: * Searchable inventory and shopping pages * A shopping cart * A place for customers to register when they make purchases * A checkout process to make the purchase Within this main process, there are a bunch of other needs that must be met, as follows: * We want to track the date of the last purchase a customer make so we can offer incentives and discounts based on the last time they shopped. * We will offer sales based on the number of different items that a person purchases. * We...

Words: 2845 - Pages: 12