Question
// This lab has the programmer create a struct named Card // and then makes a deck of cards using it //#include stdafx.h #include #include
// This lab has the programmer create a struct named Card // and then makes a deck of cards using it
//#include "stdafx.h" #include #include
using namespace std;
const string suits[] = {"spades","hearts","diamonds","clubs"}; const string values[] = {"ace","2","3","4","5","6","7","8","9", "10","jack","queen","king"};
// struct Card represents a playing card, so has two // parts the suit and the value, both strings // YOUR CODE HERE
struct Card { string suit; string value; };
// prototypes Card makeCard( int s, int v ); int userPick();
int main() { // welcome to the program cout
// declare an array of 52 Cards, call it deck. // YOUR CODE HERE Card deck[52];
// run double nested loop on suit and value to fill // up a deck of cards with 4 suits x 13 values each. for ( int s=0; s
// let the user pick a number from 0-51 (or -1 to quit) // and show the Card at that index in the deck. int i; while ( (i=userPick()) >= 0 ) { // show the ith card in the deck // YOUR CODE HERE
} cout
return 0; }
// ask user to pick card inex (0-51), returns the int // -1 also allowed, that's the quit signal int userPick() { int n=-1; do { cout >n; } while (n51 ); return n; }
// make a Card struct using suits[s] and values[v] // from the constant lists at the top of the program. // Return the Card. Note: there is no erro checking // here, be careful. Card makeCard( int s, int v ) { Card c;
// assign the two parts of c values from suit[] // and values[]. // YOUR CODE HERE
return c; }
The only part you can add some code is below the // YOUR CODE HERE.
and we need to make it same as expected output.
This is C++
3 14 Input 99 51 Card Struct Lab enter card number (0-51, -1 to quit): enter card number (0-51, -1 to quit): Your outpt enter card number (0-51,-1 to quit): enter card number (0-51, -1 to quit): enter card number (0-51, -1 to quit): bye Card Struct Lab enter card number (0-51, -1 to quit): card 3 is 4 of spadese enter card number (0-51, -1 to quit): card 14 is 2 f he artsd enter card number (0-51,-1 to quit) : enter card number (0-51, -1 to quit): card 51 is king of clubse enter card number (0-51, -1 to quit): bye Expected outputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started