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]
3 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:
vekshin13 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
Roman has painstakingly developed the animation for one of the objects on his slide. He can now use the Animation Painter to cop
tigry1 [53]
I think the answer is True
5 0
4 years ago
Megan says she never needs to look at the Transport Layer when she is searching for what went wrong with the network she support
lara31 [8.8K]

I'd say D: Wrong, because transporting information is what a network does, and the Transport Layer is at the heart of that layer.

Transport layer is truly at the heart of the OSI model. Its main function is to transfer application data from the source to destination. This layer provides a reliable end-to-end communication service and transfers data for the user layers above it, as well as shielding the rest of the layers below from details like message error and flow control functions. If packets get destroyed or lost during transmission, it is in the best interest of Megan to check the transport layer. Transport layer ensures that whenever something like this happens, packets must be re-transmitted.

3 0
3 years ago
Read 2 more answers
Keyshia adds an image of a triple beam balance and a
vredina [299]

Answer:

select all images

Go to the pictures tool format tab

Choose the arrange group

Choose the group Option

Explanation:

7 0
3 years ago
While Joe's wife Molly and daughter Sunny did not mind moving,his son Daniel was not too happy with the sudden change in their l
Ann [662]

It means your stupid look it up!!

6 0
3 years ago
Learning in a digital environment is also called learning.
aleksandrvk [35]

Learning in a digital environment is also called O<u>nline Learning.</u>

Explanation:

The main difference between the digital learning and the traditional form of learning is that

  • Digital Learning takes place online or virtually.
  • The traditional Learning is conducted in a classroom building.
  • Another factor that differentiate the 2 forms of learning is that the instructor or the trainer may not be present at the real-time but in a traditional training method the trainer or the instructor is present in person
6 0
4 years ago
Read 2 more answers
Other questions:
  • An electronic resume is a plain-looking document. True of False?
    6·2 answers
  • Define the term Frame Rate.
    12·1 answer
  • What component is most likely to be installed in a PC, is considered primary storage, and typically stores the operating system,
    6·1 answer
  • in a deisgn project, what two types of graphics or images is the digital artist respondsible for creating?
    11·1 answer
  • Neil holds a discussion session with his clients. He recommends the kinds of network topologies the clients should consider, acc
    9·1 answer
  • Help me with Java Coding, I don't know what I am doing wrong in driver class. Please fix in Java and upload.
    14·1 answer
  • Scanning low allows you to locate __________ before you hit them
    13·1 answer
  • HELP PLSSSSS!!! I WILL MARK BRAINLIEST FOR THE FIRST AND CORRECT ANSWER!!!
    14·2 answers
  • An EULA usually takes the form of an electronic notification that appears when installing software. The user then has a choice t
    14·1 answer
  • Weak passwords are a(n) ___________ threat
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!