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
A CRS is most commonly used for
BigorU [14]
It is mostly used to store and retrieve information
6 0
4 years ago
. What are the technical advantages of optical fibres over other communications media?
katrin [286]

Answer: The advantage of the optical fibre over the other medium of the communication are as follows:-

  • The bandwidth of the optical fibre is comparatively higher than the other communication media
  • The security in regard with the loss of data can be tracked easily as compared with other copper wire medium of communication.Thus, the security system of optical fibre is more reliable.
  • The capacity of the fibre and the transmission power is also high as compared with other media of the communication such as copper wires,etc.
  • The optical fibre is less space consuming than other communication medium.

7 0
3 years ago
You are on vacation and want to see where all the restaurants and trendy shops are in relation to your hotel. You remember
aivan3 [116]

Answer:

research

Explanation:

"Chip and PIN is the technology that lets your card machine take payments safely from your customers using their credit card or debit card"

"Augmented reality (AR) is an interactive experience of a real-world environment where the objects that reside in the real world are enhanced by computer-generated perceptual information,"

"A kiosk refers to a small, temporary, stand-alone booth used in high-traffic areas for marketing purposes."

" Digital literacy is understanding how to use web browsers, search engines, email, text, wiki, blogs"

4 0
4 years ago
Drag each tile to the correct box.
garri49 [273]
I think select the video insert select the movie option under illustrations resize the video player then select the insert tab i’m not 100 percent sure tho
8 0
4 years ago
Read 2 more answers
Kiaan wants to give people who attend his presentation a printed copy of the slides. Instead of printing one slide on each piece
ArbitrLikvidat [17]

Answer:

Under the Print Tab of the Backstage view of his presentation, Kiaan can print 6 slides on each piece of paper by selecting the "Full Page Slides" which is under settings.

Once that is done, he will be presented with an array of choices.

He is to select whether to print 6 pages/sheet vertically or horizontally under the "Handouts" section.

Thereafter, he can proceed to click on "Print".

Cheers!

5 0
3 years ago
Other questions:
  • Technician A says that if a valve is open when a piston rises to the very top of a cylinder, the piston may actually strike the
    13·1 answer
  • Content controls cannot be removed, only edited. Please select the best answer from the choices provided
    10·1 answer
  • In Java an abstract class cannot be sub-classed<br><br> ?? True<br><br> ?? False
    8·1 answer
  • The World Wide Web (not the Internet) went live in this decade:
    8·2 answers
  • Implement (in Java) the radixSort algorithm to sort in increasing order an array of integer positive keys. public void radixSort
    13·1 answer
  • Which of the following statements is used to terminate the program when closing the frame?
    12·1 answer
  • What is 11100111 to decimal form?
    9·2 answers
  • Write a class named Movie that has fields to hold the following data: Title Studio Name Year produced Rating In the Movie class,
    14·1 answer
  • Rudy accidentally sent a sensitive work report to a personal friend named James instead one of his co-workers, who is also named
    6·1 answer
  • Disadvantages of the divisional organization structure are _____. each division is able to operate independently from the parent
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!