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
stepladder [879]
3 years ago
9

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

llows:a. When the program begins, the user enters his or her choice of "rock", "paper", or "scissors" at the keyboard using a menu in a function, userChoice, that returns a character.b. Next, there should be a function, computerChoice, that generates the computer’s play. A random number in the range of 1 through 3 is generated. (NOTE: You’ll have to do some research on how to create random numbers correctly.) 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. The computer’s choice is returned as a character.c. After, a function, determineWinner, will determine the winner between the user’s choice vs. the computer’s choice. (NOTE: It will return nothing, but it will take in the user’s choice and the computer’s choice as the two arguments.) The result is selected according to the following rules:i. If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.)ii. If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.)iii. If one player chooses paper and the other player chooses rock, then paper wins. (Paper wraps rock.) iv. If both players make the same choice, the game ends in a draw and there is no winner.d. Finally, after a result is selected, there should be a function, playAgain, in which the player should have the option of playing again. This should return a boolean. Be sure that the program contains at least the four functions mentioned in parts a – d.
Computers and Technology
1 answer:
fgiga [73]3 years ago
4 0

A program that lets the user play the game of Rock, Paper, Scissors against the computer.

Explanation:

a. When the program begins, the user enters his or her choice of "rock", "paper", or "scissors" at the keyboard using a menu in a function, userChoice, that returns a character.

b. Next, there should be a function, computerChoice, that generates the computer’s play. A random number in the range of 1 through 3 is generated. (NOTE: You’ll have to do some research on how to create random numbers correctly.) 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. The computer’s choice is returned as a character

c. After, a function, determineWinner, will determine the winner between the user’s choice vs. the computer’s choice.The result is selected according to the following rules:

d. Finally, after a result is selected, there should be a function, playAgain, in which the player should have the option of playing again. This should return a boolean.

#include <iostream>

#include <stdlib.h>

int main() {

srand (time(NULL));

int computer = rand() % 3 + 1;

int user = 0;

 std::string roc = "1) Rock\n";

 std::string pap = "2)Paper\n";

 std::string sci = "3) Scissors\n";

std::cout << "rock paper scissors!\n";

std::cout << roc;

std::cout << pap;

std::cout << sci;

std::cout << "Choose: ";

std::cin >> user;

std::cout << "\nYou  choose ";

 switch(user){

   case 1 :

    std::cout << roc;

    break;

   case 2 :

    std::cout << pap;

    break;

   case 3 :

    std::cout << sci;

    break;

   default :

    std::cout << "Invalid Option\n";

 }

std::cout << "Comp choose ";

   switch(computer){

   case 1 :

    std::cout << roc;

    break;

   case 2 :

    std::cout << pap;

    break;

   case 3 :

    std::cout << sci;

    break;

   default :

    std::cout << "Invalid Option\n";

 }

 if(user == computer){

   std::cout << "Draw Game\n";

 }

 else if(user == 1 && computer == 3){

   std::cout << "You Win\n";

 }

 else if(user == 3 && computer == 2){

   std::cout << "You Win\n";

 }

 else if(user == 2 && computer == 1){

   std::cout << "You Win\n";

 }

 else{

   std::cout << "Computer Wins!\n";

 }

 

}

You might be interested in
In a brief essay explain the security vulnerabilities of transition methods (6to4, etc.)
vlabodo [156]

Answer:

While transiting from IPv4  to IPv6, many offices and companies use both the protocols (Ipv4 and IPv6) at the same time. This scenario can increase the risk  rate of attack twice. All the flaws and vulnerabilities could be overlooked easily when transition is done.

On the other hand, while transiting Ipv6 to IPv4, the router does not tells or depicts that the communication is appropriate or if it could be used as a part of DoS attack that make it so much harder to trace the origin back.

The reason for the vulnerability of Transport Relay Translators (TRT) is that they do not apply Internet Protocol Security (IPSec) and thats why they are not secure.

i hope it will help you!

7 0
3 years ago
John's boss asks for a recommendation for connecting the company network to a small satellite building about 1 km from the main
tresset_1 [31]

Answer:

C. Ethernet over multi mode fiber .

Explanation:

Given that the distance to be covered is 1 km. Multi-mode optic fiber is best suited for short distances of up to 2 km and can withstand harsh environments with less signal attenuation. Single mode fiber is best suited long distance of up to 200 km or more and is expensive as compared to multi-mode fiber Ethernet over twisted pair is best for indoor use and can only cover very short distances. Although UTP and STP are relatively cheap they cannot withstand harsh environments without great signal loss.

4 0
4 years ago
Describe how computer is in the last 35 years
lesantik [10]
Earlier there were no ic's but vacuum tubes or  transisters,..
making computer big , so big in that time, with low speed and  memory
4 0
4 years ago
A user complains that Skype drops her videoconference calls and she must reconnect. At which layer of the OSI model should you b
umka2103 [35]

Answer: Application layer

Explanation:

Application layer of OSI(Open system interconnection) that is responsible for interfacing the communication with the user by displaying information or message. It maintains the transmission of file and assessment, emailing faculty, using network services etc.

  • According to the question,if any Skype user has complain regarding video call drop while conferencing then application is responsible to solve the issue.
  • This layer will be the starting point of troubleshoot by approaching to network resources.As call drop can occur due to network service, congestion or resource issue.
4 0
3 years ago
Configuring a firewall to ignore all incoming packets that request access to a specific port is known as ____.
Sati [7]

Answer: Logical Point Blocking

Explanation:

4 0
1 year ago
Other questions:
  • You have been hired to set up a network for XYZ Enterprises. What factors will you consider to determine the type of network nee
    7·2 answers
  • What happened to Henry at the end of Chapter 4 in Bendy and the ink machine?
    9·2 answers
  • Ben works at a top accounting firm in Salt Lake City and his responsibilities include developing individual and departmental goa
    9·1 answer
  • Which ieee 802.11 standard provides for throughput of up to 7 gbps?
    8·1 answer
  • What does Tristan need to do to add a row at the<br> bottom of the table shown?
    6·1 answer
  • A ________ is a single media file including art, sound, animation, or movies.
    9·1 answer
  • Shanice wants to make her résumé. Which of these is a recommended practice for her?
    5·1 answer
  • Name two different ways you can bring up the my computer folder
    9·2 answers
  • Segregation based on laws is called _____
    11·2 answers
  • Topic: Graphs.1.) Bob loves foreign languages and wants to plan his courseschedule for the following years. He is interested in
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!