Free Essay

Rock Paper and Scissors

In: Computers and Technology

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

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

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

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......

Words: 2354 - Pages: 10

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......

Words: 4161 - Pages: 17

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,......

Words: 2239 - Pages: 9

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......

Words: 554 - Pages: 3

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

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......

Words: 801 - Pages: 4

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. *......

Words: 2845 - Pages: 12

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......

Words: 352 - Pages: 2

Premium Essay

Earth Science

...2012-2013 Web Site: Phone Number: Email: Office Hours: https://www.tracy.k12.ca.us/sites/kwedel/Pages/ClassInformation.aspx EARTH SCIENCE SYLLABUS 209-830-3360 ext 2509 kwedel@tusd.net Wednesday 3:00 pm to 4:00 pm or by arrangement Welcome to Earth Science – the study of the world around you. Our topics will include Astronomy (study of outer space), Geology (study of rocks, earthquakes, volcanoes and plate tectonics), Meteorology (study of the atmosphere, climate and climate change), and Oceanography (study of the oceans and water systems). This course will use hands-on experimentation, activities, and direct instruction. You will be enabled to learn the ‘how’ and ‘why’, not just the ‘what’ of science. I will show how Earth Science is relevant in your everyday life; you must provide the willingness to learn. MATERIALS Textbook: Bring to class everyday: Optional but useful: Earth Science, published by Holt (Please keep your textbook at home.) Composition Book and Science Binder/folder with paper - see below Pencil and/or Pen (dark blue or black ink only) Calculator, colored pens and/or pencils, scissors, ruler RULES AND EXPECTATIONS 1. 2. 3. 4. 5. Arrive prepared to learn (mentally ready and equipped with the correct materials) Never prevent others from learning (inappropriate behavior or talking) Always follow safety rules during lab (prevent injures) Do not take or damage any classroom equipment Participate in class discussions, activities and......

Words: 1424 - Pages: 6

Premium Essay

Earth Science

...2012-2013 Web Site: Phone Number: Email: Office Hours: https://www.tracy.k12.ca.us/sites/kwedel/Pages/ClassInformation.aspx EARTH SCIENCE SYLLABUS 209-830-3360 ext 2509 kwedel@tusd.net Wednesday 3:00 pm to 4:00 pm or by arrangement Welcome to Earth Science – the study of the world around you. Our topics will include Astronomy (study of outer space), Geology (study of rocks, earthquakes, volcanoes and plate tectonics), Meteorology (study of the atmosphere, climate and climate change), and Oceanography (study of the oceans and water systems). This course will use hands-on experimentation, activities, and direct instruction. You will be enabled to learn the ‘how’ and ‘why’, not just the ‘what’ of science. I will show how Earth Science is relevant in your everyday life; you must provide the willingness to learn. MATERIALS Textbook: Bring to class everyday: Optional but useful: Earth Science, published by Holt (Please keep your textbook at home.) Composition Book and Science Binder/folder with paper - see below Pencil and/or Pen (dark blue or black ink only) Calculator, colored pens and/or pencils, scissors, ruler RULES AND EXPECTATIONS 1. 2. 3. 4. 5. Arrive prepared to learn (mentally ready and equipped with the correct materials) Never prevent others from learning (inappropriate behavior or talking) Always follow safety rules during lab (prevent injures) Do not take or damage any classroom equipment Participate in class discussions, activities and......

Words: 1424 - Pages: 6

Premium Essay

Fis 240 Learning Consultant / Tutorialrank.Com

...FIS 240 Entire Course (UOP) For more course tutorials visit www.tutorialrank.com FIS 240 Week 1 CheckPoint: Is Time on My Side (UOP) FIS 240 Week 1 DQs (UOP) FIS 240 Week 2 CheckPoint: Risk Assessment Matrix (UOP) FIS 240 Week 2 Exercise: Risk and Reward: First 10% (UOP) FIS 240 Week 2 Assignment: What’s In It for Me? (UOP) FIS 240 Week 3 DQs (UOP) FIS 240 Week 3 CheckPoint: Primary and Secondary…Not Just Schools (UOP) FIS 240 Week 4 CheckPoint: Investment Comparison Problems (UOP) FIS 240 Week 4 Assignment: Embracing Diversity (UOP) FIS 240 Week 5 CheckPoint: Rock, Paper, Scissors, and Other Investment Techniques (UOP) FIS 240 Week 5 DQs (UOP) FIS 240 Week 6 CheckPoint: So Many Businesses, So Little Money PART 1 OF 2 (UOP) FIS 240 Week 6 CheckPoint: So Many Businesses, So Little Money PART 2 OF 2 (UOP) FIS 240 Week 6 Assignment: Analyze This (UOP) FIS 240 Week 7 DQs (UOP) FIS 240 Week 7 CheckPoint: Income that Sticks PART 1 OF 2 (UOP) FIS 240 Week 7 CheckPoint: Income that Sticks PART 2 OF 2 (UOP) FIS 240 Week 8 CheckPoint: Lifetime Investment Matrix PART 1 OF 2 (UOP) FIS 240 Week 8 CheckPoint: Lifetime Investment Matrix PART 2 OF 2 (UOP) FIS 240 Week 8 Assignment: Living the Easy Life (UOP) FIS 240 Capstone Discussion Question (UOP) FIS 240 Final Project: Investment Policy and Portfolio Evaluation (UOP) ____________________________________________________ FIS 240 Week 1 CheckPoint: Is Time on My Side (UOP) For more course tutorials......

Words: 643 - Pages: 3

Free Essay

Photography

...Photography Photography is undoubtedly one of the most important inventions in history -- it has truly transformed how people conceive of the world. Now we can "see" all sorts of things that are actually many miles -- and years -- away from us. Photography lets us capture moments in time and preserve them for years to come Today, photography is characterized by a rapid growth in the development of technology and ideas. Each year, millions of pictures are taken and an astonishing array of new films, cameras and imaging systems enter the market. One of the great attractions of the photography field is the ease with which basic skills can be learned. The word ‘photography’ comes from the Greek term ‘drawing with light’. Without light there is no photograph. Photography is about seeing, balancing and interpreting the light. Composition of Photography The Camera: The materials that are usually used in creating a camera are metal, glass, plastic, wood, and mirrors. The Film: Collodion: This substance transformed photography. This a viscous mixture of gun cotton that is dissolved in alcohol that then creates a thin film. It is then mixed with silver bromide, silver iodide or silver chloride. This substance reduced exposure time to seconds instead of hours. Film: The first type of camera film was produced when the collodion was combined with celluloid, a flexible plastic. This film started to be sold with “Kodak” in 1889 along with the worlds first box......

Words: 1261 - Pages: 6