game #4 player 1 : rock player 2 : rock playerl = 1, player2 = 1 Notice this game scores didn't cha game #5 player 1 : rock player 2 : paper playerl = 1, player2 = 2 game #6 player 1 : scissors player 2 : rock playerl = 1, player2 = 3 PLAYER2 WINS THE MATCH!

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

Instructions for both assignments can be found in the picture linked to this post. The programs must be written in c++ and requires that the random number generator be seeded like this program:

Program 3.25

// This program demonstrates random numbers.
#include <iostream>
#include <cstdlib>    // For rand and srand
#include <ctime>      // For the time function
using namespace std;
 
int main()
{
// Get the system time.
unsigned seed = time(0);
 
// Seed the random number generator.
srand(seed);
 
// Display three random numbers.
cout << rand() << endl;
cout << rand() << endl;
cout << rand() << endl;
return 0;
}
**Rock, Paper, Scissors Game Summary**

**Game #4**
- Player 1: Rock
- Player 2: Rock
- Score: Player 1 = 1, Player 2 = 1
- *Note: This game was a tie, so the scores didn’t change.*

**Game #5**
- Player 1: Rock
- Player 2: Paper
- Score: Player 1 = 1, Player 2 = 2

**Game #6**
- Player 1: Scissors
- Player 2: Rock
- Score: Player 1 = 1, Player 2 = 3
- *Conclusion: Player 2 wins the match!*

**Important Notes:**
6. Due to potential ties, it is impossible to predict the number of games beforehand.
7. It's recommended to use capitalized constants to represent rock, paper, and scissors in your program instead of hard-coded numbers.
Transcribed Image Text:**Rock, Paper, Scissors Game Summary** **Game #4** - Player 1: Rock - Player 2: Rock - Score: Player 1 = 1, Player 2 = 1 - *Note: This game was a tie, so the scores didn’t change.* **Game #5** - Player 1: Rock - Player 2: Paper - Score: Player 1 = 1, Player 2 = 2 **Game #6** - Player 1: Scissors - Player 2: Rock - Score: Player 1 = 1, Player 2 = 3 - *Conclusion: Player 2 wins the match!* **Important Notes:** 6. Due to potential ties, it is impossible to predict the number of games beforehand. 7. It's recommended to use capitalized constants to represent rock, paper, and scissors in your program instead of hard-coded numbers.
**Menu-Driven Program Overview**

This program features a menu-driven interface, which appears as follows:

**Menu**

1. Play rock-paper-scissors  
2. Play Yahtzee  
3. Exit  

*Enter your choice:*

---

**Specifications for the Menu**

1. The program persists until option #3 (Exit) is selected by the user.
2. If an invalid choice is made (e.g., selecting 5), the program will display an error message in a complete sentence but continue running.
3. To refresh the screen before displaying the menu, use the following code:

   ```cpp
   cout << "Press <Enter> to continue" << endl;
   cin.get();
   system("cls");
   ```

4. Utilize a `switch` statement to handle user input efficiently.

---

**Rock-Paper-Scissors Specifications**

1. Two players pick between rock, paper, or scissors and their selections are compared.

   a. Rock defeats scissors (rock breaks or dulls scissors)  
   b. Scissors defeat paper (scissors cut paper)  
   c. Paper defeats rock (paper covers rock)  

2. Prompt the user to specify the number of games required to win a match. Ensure this is an odd number.
   - Use a loop to validate input and confirm it's odd.

3. The program will randomly generate choices for both players using a random number generator. Refer to section 3.9 in the text for generating random numbers.

4. Seed the random number generator as demonstrated in Program 3-25.

5. Display each game in the match and the scores afterward. If the user specifies three game wins to achieve victory, the output should resemble this:

   **Example Game Outcomes:**

   ```
   game #1
   player1: rock
   player2: scissors
   player1 = 1, player2 = 0

   game #2
   player1: paper
   player2: paper
   player1 = 1, player2 = 0

   game #3
   player1: paper
   player2: scissors
   player1 = 1, player2 = 1
   ```

   *Note: If a game ends in a tie, scores remain unchanged.*

---

This setup defines the rules and flow of the menu-driven program, focusing on robustness and user-friendliness.
Transcribed Image Text:**Menu-Driven Program Overview** This program features a menu-driven interface, which appears as follows: **Menu** 1. Play rock-paper-scissors 2. Play Yahtzee 3. Exit *Enter your choice:* --- **Specifications for the Menu** 1. The program persists until option #3 (Exit) is selected by the user. 2. If an invalid choice is made (e.g., selecting 5), the program will display an error message in a complete sentence but continue running. 3. To refresh the screen before displaying the menu, use the following code: ```cpp cout << "Press <Enter> to continue" << endl; cin.get(); system("cls"); ``` 4. Utilize a `switch` statement to handle user input efficiently. --- **Rock-Paper-Scissors Specifications** 1. Two players pick between rock, paper, or scissors and their selections are compared. a. Rock defeats scissors (rock breaks or dulls scissors) b. Scissors defeat paper (scissors cut paper) c. Paper defeats rock (paper covers rock) 2. Prompt the user to specify the number of games required to win a match. Ensure this is an odd number. - Use a loop to validate input and confirm it's odd. 3. The program will randomly generate choices for both players using a random number generator. Refer to section 3.9 in the text for generating random numbers. 4. Seed the random number generator as demonstrated in Program 3-25. 5. Display each game in the match and the scores afterward. If the user specifies three game wins to achieve victory, the output should resemble this: **Example Game Outcomes:** ``` game #1 player1: rock player2: scissors player1 = 1, player2 = 0 game #2 player1: paper player2: paper player1 = 1, player2 = 0 game #3 player1: paper player2: scissors player1 = 1, player2 = 1 ``` *Note: If a game ends in a tie, scores remain unchanged.* --- This setup defines the rules and flow of the menu-driven program, focusing on robustness and user-friendliness.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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