Program it structure with playing cards guessing
Answers
Answer:
MARK ME AS BRAINLIEST
Explanation:
This structure uses separate members to hold the number of the card and the suit. The number runs from 2 to 14, where 11, 12, 13, and 14 represent the jack, queen, king, and ace, respectively (this is the order used in poker). The suit runs from 0 to 3, where these four numbers represent clubs, diamondbacks, and spades.
Here’s the listing for CARDS:
II ca rds. cpp
II demonstrates structures using playing cards
#include <iostream>
using namespace std;
const int clubs = 0;
const int diamonds = 1;
const int hearts= 2;
const int spades = 3;
const int jack = 11;
const int queen = 12;
const int king = 13;
const int ace = 14;
/////////////////////////////////////////
struct card .
{
int number; 1/2 to 1′, jaCk, quaen, king, aCa
int suit; Ilclubs, dia.onds, heart., apad••
}:
///////////////////////////////////////
int lIain()
{
card temp, cho••n, prize; Iidefine cards
int pos!tion :
card card1 • { 7, clubs }j Ilinitialize card1
cout « ‘Card 1 i. the 1 of c~s\n’j
card card2 • { Jack, hearts }j lIinitialize card
cout « ‘Card 2 is t~ jack of ~.rt.\n”;
card card3 • { aCI, spade. }j Ilinitializa carda
cout « ‘Card 3 il the aea of .pad••\n·:
prize =card3: Ilcopy this card, to r…-blr.1t
cout « ‘I’m swapping card 1 and card 3\n’:
temp.~ card3: card3 • card1j card,.• ta.p;
cout « ‘I’m swapping card a and card 3\n”j
tlmp a card3; card3 • carda; carda • tl~;
cout « ‘I’m swapping card 1 and card 2\n”:
temp.- card2: card2 • cardtj card1 • te.p:
cout « ‘Now, where (1, 2, or 3) 1$ the aCI of spadel? “j
cin » position;
switch (position)
{
case 1: chosen • card1; break:
case 2: chosen· card2:·brea~;
case 3: chosen ~ card3: break;
}
if(chosen.number •• prize.number &&
chosen.suit =- prize .•uit~
cout « ‘That’s rightl V.ouwinl\n~;
else
cout « “Sorry. You lose:\n”:
return I:
}
II compare cards
Heres some sample interaction with the program:
Card 1 is the 7 of clubs
car~ 2 is the jack of helrts
Card 3 is the Ice of spldes
I’m swapping card 1 and card 3
I’m swapping card 2 and card 3
I’m swapping card 1 and card 2
Now, where (1, 2, or 3) is the ace of spades? 3
&orry, You lose,