1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
STALIN [3.7K]
2 years ago
5

Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follo

ws. 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 computer’s choice yet.) 2. The user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard. (You can use a menu if you prefer.) 3. The computer’s 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 rock wins. (The rock breaks the scissors.) • If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.) • If one player chooses paper and the other player chooses rock, then paper wins. (Paper wraps rock.) • If both players make the same choice, the game must be played again to determine the winner. Be sure to divide the program into functions that perform each major task. Include the code and the console output from running your program with test inputs in your report.
Computers and Technology
1 answer:
vekshin12 years ago
3 0

#include <iostream>

#include <ctime>

#include <conio.h>

using namespace std;

bool player_won (int player, int computer)

{

   switch (player)

   {

   case 1:

       if (computer==2)

           return false;

       else return true;

   case 2:

       if (computer==3)

           return false;

       else return true;

   case 3:

       if (computer==1)

           return false;

       else return true;

   }

}

main ()

{

   cout<<"Rock, paper scissors by TheMaster999"<<endl;

   srand (time(NULL));

   while (true)

   {

       int computer=rand()%3+1;

       int player;

       cout<<"If u choose rock type 1, if u choose paper type 2, if u choose scissors type 3"<<endl;

       cin>>player;

       if (player==computer)

           cout<<"Draw, play again"<<endl;

       else if (player_won(player,computer))

       {

           cout<<"Congratulations, you won!"<<endl;

           break;

       }

       else

       {

           cout<<"You lost :("<<endl;

           break;

       }

   }

   cout<<"Thank you, for playing my game"<<endl;

   getch();

   return 0;

}

You might be interested in
Which function prompts the user to enter information?
Rzqust [24]

Answer:

input() prompts the user to enter information

6 0
3 years ago
Read 2 more answers
Objectives ** WILL GIVE BRAINIST PLEASE**
mamaluj [8]

Answer:

of which std this question is

8 0
2 years ago
Read 2 more answers
How do you post a picture on brainly? How do you also lower the points to like 5,brainless to the first understandable answers
Morgarella [4.7K]
To post a picture you just need to click on the clipper looking thing 
3 0
3 years ago
Write a function ComputeVal that takes two integer parameters and returns the product of the two parameters plus 9. Ex: ComputeV
Romashka-Z-Leto [24]

Answer:

#include <iostream>

using namespace std;

/* Your code goes here */

int main() {

  int input1, input2;

  int result;

 

  cin >> input1;

  cin >> input2;

 

  result = ComputeNum(input1, input2);

 

  cout << result << endl;

  return 0;

Explanation:

6 0
2 years ago
whats that system tool the rearranges files and unused space on the hard drive so programs can run faster
Zolol [24]
The Disk Fragmenter.
5 0
2 years ago
Read 2 more answers
Other questions:
  • // PrintStrings // Traverse the 2D character array "strings" and print each of the contained strings.// See the example outputs
    10·1 answer
  • Advancements in technology that might be helpful for individuals who need accommodations to perform computer tasks include _____
    15·2 answers
  • Please draw a diagram of a complete graph with 5 vertices (K5), its adjacency matrix and adjacency list representations.
    5·1 answer
  • Which of the following is NOT a function of the Web Accessibility Initiative​ (WAI)? A. Offering links to a variety of software
    10·1 answer
  • Sarah has prepared a project document about the small and medium-sized companies in the United States. While proofreading, she r
    11·2 answers
  • Hi, please help me complete my Database Development 2 hw by completing what should been done from the document and show the code
    11·1 answer
  • (20points)
    6·1 answer
  • A spreadsheet contains the maximum weight and maximum height for fifty dog breeds. The breeds are located in rows, and the weigh
    5·1 answer
  • Hey plz help me with this<br>What is malware short for?​
    13·1 answer
  • the image on the right was prooduced by a computer. it shows a complex molecu;e consisting of many atoms. what would be an advan
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!