I need to combine these programs into one with a menu system that looks like this: Menu ==== 1. Play Rock-Paper-Scissors 2. Play Yahtzee 3. Exit   Program #1 #include #include #include   using namespace std;   int main() {     unsigned seed = time(0);     srand(seed);       int maxWins = 0, player1Wins = 0, player2Wins = 0;       while (maxWins % 2 == 0) {         cout << "Enter an odd number: ";         cin >> maxWins;     }       int count = 1;     while (player1Wins < maxWins && player2Wins < maxWins) {         int player1 = rand() % 3;         int player2 = rand() % 3;           string player1Choice, player2Choice;           if (player1 == 0) {             player1Choice = "rock";         }         else if (player1 == 1) {             player1Choice = "scissors";         }         else {             player1Choice = "paper";         }           if (player2 == 0) {             player2Choice = "rock";         }         else if (player2 == 1) {             player2Choice = "scissors";         }         else {             player2Choice = "paper";         }           cout << "game #" << count << endl;         cout << "player1 : " << player1Choice << endl;         cout << "player2 : " << player2Choice << endl;           if (player1Choice == "rock") {             if (player2Choice == "scissors") {                 player1Wins++;             }             else if (player2Choice == "paper") {                  player2Wins++;                             }         }         else if (player1Choice == "scissors") {             if (player2Choice == "rock") {                          player2Wins++;                              }             else if (player2Choice == "paper") {                    player1Wins++;                              }         }         else if (player1Choice == "paper") {             if (player2Choice == "rock") {                          player1Wins++;                              }             else if (player2Choice == "scissors") {                 player2Wins++;                              }         }         cout << "player1 = " << player1Wins << ", player2 = " << player2Wins << endl;          count++;                                   }       if (player1Wins > player2Wins) {         cout << "PLAYER1 WINS THE MATCH" << endl;     }     else {         cout << "PLAYER2 WINS THE MATCH" << endl;     }     return 0; }   Program #2 #include #include #include   using namespace std;   int main() {     unsigned seed = time(0);     srand(seed);     int i = 1;       while (true) {           int dice1 = rand() % 6 + 1;         int dice2 = rand() % 6 + 1;         int dice3 = rand() % 6 + 1;         int dice4 = rand() % 6 + 1;         int dice5 = rand() % 6 + 1;             cout << "Roll " << i << " : " << dice1 << " " << dice2 << " " << dice3 << " " << dice4 << " " << dice5;           if (dice2 != dice1 && dice3 != dice1 && dice3 != dice2 && dice4 != dice3 && dice4 != dice2 && dice4 != dice1 && dice5 != dice4 && dice5 != dice3 && dice5 != dice2 && dice5 != dice1) {             cout << " No matches this time!";         }                 else if (dice1 == dice2 && dice2 == dice3 && dice3 == dice4 && dice4 == dice5) {             cout << "\nYAHTZEE" << endl;             return 0;            }         cout << endl;         i++;                     }     return 0; }

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

I need to combine these programs into one with a menu system that looks like this:

Menu

====

1. Play Rock-Paper-Scissors

2. Play Yahtzee

3. Exit

 

Program #1

#include<iostream>

#include<cstdlib>

#include<ctime>

 

using namespace std;

 

int main()

{

    unsigned seed = time(0);

    srand(seed);

 

    int maxWins = 0, player1Wins = 0, player2Wins = 0;

 

    while (maxWins % 2 == 0) {

        cout << "Enter an odd number: ";

        cin >> maxWins;

    }

 

    int count = 1;

    while (player1Wins < maxWins && player2Wins < maxWins) {

        int player1 = rand() % 3;

        int player2 = rand() % 3;

 

        string player1Choice, player2Choice;

 

        if (player1 == 0) {

            player1Choice = "rock";

        }

        else if (player1 == 1) {

            player1Choice = "scissors";

        }

        else {

            player1Choice = "paper";

        }

 

        if (player2 == 0) {

            player2Choice = "rock";

        }

        else if (player2 == 1) {

            player2Choice = "scissors";

        }

        else {

            player2Choice = "paper";

        }

 

        cout << "game #" << count << endl;

        cout << "player1 : " << player1Choice << endl;

        cout << "player2 : " << player2Choice << endl;

 

        if (player1Choice == "rock") {

            if (player2Choice == "scissors") {

                player1Wins++;

            }

            else if (player2Choice == "paper") { 

                player2Wins++;                

            }

        }

        else if (player1Choice == "scissors") {

            if (player2Choice == "rock") {         

                player2Wins++;                 

            }

            else if (player2Choice == "paper") {   

                player1Wins++;                 

            }

        }

        else if (player1Choice == "paper") {

            if (player2Choice == "rock") {         

                player1Wins++;                 

            }

            else if (player2Choice == "scissors") {

                player2Wins++;                 

            }

        }

        cout << "player1 = " << player1Wins << ", player2 = " << player2Wins << endl; 

        count++;                              

    }

 

    if (player1Wins > player2Wins) {

        cout << "PLAYER1 WINS THE MATCH" << endl;

    }

    else {

        cout << "PLAYER2 WINS THE MATCH" << endl;

    }

    return 0;

}

 

Program #2

#include<iostream>

#include<cstdlib>

#include<ctime>

 

using namespace std;

 

int main()

{

    unsigned seed = time(0);

    srand(seed);

    int i = 1;  

    while (true) {

 

        int dice1 = rand() % 6 + 1;

        int dice2 = rand() % 6 + 1;

        int dice3 = rand() % 6 + 1;

        int dice4 = rand() % 6 + 1;

        int dice5 = rand() % 6 + 1;

 

 

        cout << "Roll " << i << " : " << dice1 << " " << dice2 << " " << dice3 << " " << dice4 << " " << dice5;

 

        if (dice2 != dice1 && dice3 != dice1 && dice3 != dice2 && dice4 != dice3 && dice4 != dice2 && dice4 != dice1 && dice5 != dice4 && dice5 != dice3 && dice5 != dice2 && dice5 != dice1) {

            cout << " No matches this time!";

        }

 

     

        else if (dice1 == dice2 && dice2 == dice3 && dice3 == dice4 && dice4 == dice5) {

            cout << "\nYAHTZEE" << endl;

            return 0;   

        }

        cout << endl;

        i++;                

    }

    return 0;

}

Expert Solution
steps

Step by step

Solved in 3 steps with 9 images

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE 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