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
DedPeter [7]
2 years ago
12

Write a program that plays the popular scissor-rockpaper game. (A scissor can cut a paper, a rock can knock a scissor, and a pap

er can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws. Here are sample runs:
scissor (0), rock (1), paper (2): 1
The computer is scissor. You are rock. You won
scissor (0), rock (1), paper (2): 2
The computer is paper. You are paper too. It is a draw
Computers and Technology
1 answer:
kolbaska11 [484]2 years ago
8 0

Answer:

import random

computer = random.randint(0, 2)

user = int(input("scissor (0), rock (1), paper (2): "))

if computer == 0:

   if user == 0:

       print("The computer is scissor. You are scissor too. It is a draw")

   elif user == 1:

       print("The computer is scissor. You are rock. You won")

   elif user == 2:

       print("The computer is scissor. You are paper. Computer won")

elif computer == 1:

   if user == 0:

       print("The computer is rock. You are scissor. Computer won")

   elif user == 1:

       print("The computer is rock. You are rock too. It is a draw")

   elif user == 2:

       print("The computer is rock. You are paper. You won")

elif computer == 2:

   if user == 0:

       print("The computer is paper. You are scissor. You won")

   elif user == 1:

       print("The computer is paper. You are rock. Computer won")

   elif user == 2:

       print("The computer is paper. You are paper too. It is a draw")

Explanation:

*The code is in Python.

Import the random to be able to generate number number

Generate a random number between 0 and 2 (inclusive) using randint() method and set it to the computer variable

Ask the user to enter a number and set it to the user variable

Check the value of computer the computer variable:

If it is 0, check the value of user variable. If user is 0, it is a draw. If user is 1, user wins. If user is 2, computer wins

If it is 1, check the value of user variable. If user is 0, computer wins. If user is 1, it is a draw. If user is 2, user wins

If it is 2, check the value of user variable. If user is 0, user wins. If user is 1, computer wins. If user is 2, it is a draw

You might be interested in
How to do GCD on small basic?​
Alekssandra [29.7K]
The other person is right
7 0
2 years ago
Wap in java to complete the following (16*1) +(14*2) +(12*3) +(10*4) +(8*5) +(6*6) +(4*7)​
vladimir1956 [14]

Answer:

It goes like:

public class Program

{

public static void main(String[] args)

{

int j=18;

int sum=0;

for (int i =1; i<7; i++)

{

sum=sum+(i*(j-2));

j=j-2;

}

System.out.println(sum);

}

}

Explanation:

<u>Variables used: </u>

j : controls the first number in product and decreases by 2 each time the loop runs.

sum: saves the values of addition as the loop runs.

3 0
2 years ago
What are rules that enforce basic and fundamental information-based constraints?
irga5000 [103]
The
answer should be C.
8 0
3 years ago
Who wants to give free points to me?
Bad White [126]

Answer:

I can :) just comment lol

3 0
3 years ago
Read 2 more answers
What are the reasons why is it necessary to evaluate online sources and content?
marissa [1.9K]
1) You don't know if the source is reliable. 
2) It is better to cite reliable sources so.
7 0
3 years ago
Other questions:
  • When programming, the word "execute" means which of these?
    13·1 answer
  • 7.14 LAB: Word frequencies Write a program that reads a list of words. Then, the program outputs those words and their frequenci
    10·1 answer
  • Tom's Art Supplies used to sell art supplies through mail order catalogs, but the company's order takers often had difficulty de
    9·1 answer
  • Rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) with ever
    12·1 answer
  • If you have an equipment failure while driving on an expressway, you should
    8·1 answer
  • It is important to know the terms of use of any website because why
    12·2 answers
  • NO LINKS OR SPAMS THEY WILL BE REPORTD<br><br> Click here for 50 points
    5·2 answers
  • What will the computer do in response to a line of code reading # name = input("What is your name?")
    7·1 answer
  • Being a part of an organization or giving back to the community is which rewards of work factor?
    6·1 answer
  • The second generation of computer languages is a higher-level language than
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!