Assignment 5B: Keeping Score. Now that we know about arrays, we can keep track of when events occur during our program. To prove this, let's create a game of Rock-Paper-Scissors. For those not familiar with this game, the basic premise is that each player says "Rock-Paper- Scissors!" and then makes their hand into the shape of one of the three objects. Winners are determined based on the following rules: Rock beats Scissors Scissors beats Paper Paper beats Rock At the start of the program, it will ask the player how many rounds of Rock-Paper- Scissors they want to play. After this, the game will loop for that many number of times. Each loop, it will ask the player what item they want to use – Rock, Paper, or Scissors. The computer will randomly generate its own item, and a winner will be determined. The game will then save the result as an element of an array, and the next round will begin. Once all the rounds have been played, the program will say "Game Over" and display a list of who won each round, in order. Hints: While the random functions we've discussed thus far can't generate words, we can associate numbers with them instead. For example, we might treat the computer randomly generating 0 as if it threw Rock. We could then use that number to access a predefined String array with "Rock", “Paper", and "Scissors" stored inside it. Sample Output #1: How many games do you want to play?: 3 Round 1: What do you want to throw?: Rock Computer threw SCISSORS! Round 2: What do you want to throw?: Paper Computer threw PAPER! Round 3: What do you want to throw?: Rock Computer threw PAPER! Game Over... Here's the recap: Player won Round 1 Tied on Round 2 Computer won Round 3

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
**Assignment 5B: Keeping Score**

In this assignment, we'll learn to track events using arrays by creating a Rock-Paper-Scissors game. The basic premise is that each player declares "Rock-Paper-Scissors!" and chooses one of the three objects. The winner is determined by these rules:

- **Rock** beats **Scissors**
- **Scissors** beats **Paper**
- **Paper** beats **Rock**

**Program Flow:**

1. The program initially asks the player how many rounds of Rock-Paper-Scissors they would like to play.
2. The game loops for the specified number of rounds. In each round:
   - The player selects Rock, Paper, or Scissors.
   - The computer randomly selects its own option.
   - A winner is determined and the result is stored in an array.
3. After all rounds are completed, the program announces "Game Over" and displays the result of each round in order.

**Hints:**

- Since we’ve learned that random functions do not generate words directly, we can use numbers to represent Rock, Paper, and Scissors. For example, the computer can generate 0 for Rock, 1 for Paper, and 2 for Scissors. These numbers can correspond to a predefined String array with "Rock", "Paper", and "Scissors".

**Sample Output #1:**

- Number of games: 3
- Round 1:
  - Player chooses: Rock
  - Computer chooses: Scissors
  - Player wins
- Round 2:
  - Player chooses: Paper
  - Computer chooses: Paper
  - Result: Tie
- Round 3:
  - Player chooses: Rock
  - Computer chooses: Paper
  - Computer wins

The system concludes with a summary of the results for each round:

- Player won Round 1
- Tied on Round 2
- Computer won Round 3

"Game Over…" is displayed at the end.
Transcribed Image Text:**Assignment 5B: Keeping Score** In this assignment, we'll learn to track events using arrays by creating a Rock-Paper-Scissors game. The basic premise is that each player declares "Rock-Paper-Scissors!" and chooses one of the three objects. The winner is determined by these rules: - **Rock** beats **Scissors** - **Scissors** beats **Paper** - **Paper** beats **Rock** **Program Flow:** 1. The program initially asks the player how many rounds of Rock-Paper-Scissors they would like to play. 2. The game loops for the specified number of rounds. In each round: - The player selects Rock, Paper, or Scissors. - The computer randomly selects its own option. - A winner is determined and the result is stored in an array. 3. After all rounds are completed, the program announces "Game Over" and displays the result of each round in order. **Hints:** - Since we’ve learned that random functions do not generate words directly, we can use numbers to represent Rock, Paper, and Scissors. For example, the computer can generate 0 for Rock, 1 for Paper, and 2 for Scissors. These numbers can correspond to a predefined String array with "Rock", "Paper", and "Scissors". **Sample Output #1:** - Number of games: 3 - Round 1: - Player chooses: Rock - Computer chooses: Scissors - Player wins - Round 2: - Player chooses: Paper - Computer chooses: Paper - Result: Tie - Round 3: - Player chooses: Rock - Computer chooses: Paper - Computer wins The system concludes with a summary of the results for each round: - Player won Round 1 - Tied on Round 2 - Computer won Round 3 "Game Over…" is displayed at the end.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education