Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a program to play the Card Guessing Game . Your program must give the user the following choices: To play the game choose

C++

Write a program to play the Card Guessing Game. Your program must give the user the following choices:

To play the game choose one of the following: 1: To guess the face value only. 2: To guess the suit value only. 3: To guess the both the face and suit. 9: To end the game.

Before the start of the game, create a deck of cards (code is provided in starter code).

Before each guess, use the function random_shuffle to randomly shuffle the deck.

On a correct guess, output You won!. On an incorrect guess, output You lose!.

Note: Do not seed random_shuffle

#include

#include

#include

using namespace std;

const string face[] = {"One", "Two", "Three", "Four", "Five",

"Six", "Seven", "Eight","Nine", "Ten",

"Jack", "Queen", "King"};

const string suit[] = {"Spade", "Club", "Diamond", "Heart"};

int main() {

vector deck;

//create the deck of cards

for (int i = 0; i < 13; i++)

for (int j = 0; j < 4; j++)

deck.push_back(face[i] + " of " + suit[j])

//Write program here

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

Students also viewed these Databases questions