Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is the STARTER CODE, please code in C++. without any functions // TODO (1): #include directives and namespace statement here enum Ranks{ACE=1,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE,TEN,JACK,QUEEN,KING}; enum Suits{CLUBS=0,

image text in transcribed

this is the STARTER CODE, please code in C++. without any functions

// TODO (1): #include directives and namespace statement here

enum Ranks{ACE=1,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE,TEN,JACK,QUEEN,KING};

enum Suits{CLUBS=0, HEARTS, SPADES, DIAMONDS};

int main() {

const string LINE = "--------------------";

// TODO (2): declare variables here

string suitName, rankName;

// TODO (3): prompt user for matchword; read in the value

// TODO (4): consider declaring and initializing additional variables

// TODO (5): start output with a line

for (int suit = CLUBS; suit

// TODO (6): if suit == CLUBS, then suitName = "Clubs", , else if suit == HEARTS, then suitName = "Hearts", ...

for (int rank = ACE; rank

// TODO (7): if rank == ACE, then rankName = "Ace", ...

// TODO (8): output the current card info if the match word equals the suitName OR the match word equals the rankName

}

}

// TODO: (7) output (no matches) if nothing matched

// TODO: (8) finish output with a line

return 0;

}

Nine of Spades Ten of Spades Jack of Spades Queen of Spades King of Spades Enter match word ('.' for match all): Swords (no matches) Enter match word ('.' for match all): Ace of Clubs Two of Clubs Three of Clubs Four of Clubs Five of Clubs Nine of Diamonds Ten of Diamonds Jack of Diamonds Queen of Diamonds King of Diamonds 1 In this last example, all 52 cards will be listed. It's been shortened here for brevity. Hints 1) Output a newline after reading the user input. 2) Use an outer loop for the suits, and an inner loop for the ranks. 3) Within the loops, assign a string to the suit name and another to the rank name and if the keyword matches either, print it out 4) Use switch statements to set name variables based on the loop variables. 5) Skip printing the card name when it does NOT match the user's word. 6) You might want to count the matches, so you know when none have matched

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago