Create an enumeration to represent the four standard suits of cards (CLUBS, DIAMONDS,
HEARTS, and SPADES). Create another enumeration for the words that represent card
point-value names (TWO, THREE, and the rest of the number cards through TEN, then
JACK, QUEEN, KING, and ACE). (In many card games, the ACE is considered to have a
higher value than the KING.) Display the numeric suit and point-value names of all 52
cards. Save the file as CardDeck.cpp.
1
Expert's answer
2015-03-11T06:14:05-0400
Answer #include<iostream> #include<string> /*Display the numeric suit and point-value names of all 52 cards.Save the file as CardDeck.cpp. */ usingnamespace std; //Createan enumeration to represent the four standard suits of cards (CLUBS, DIAMONDS, HEARTS, and SPADES). enum suits {CLUBS = 1, DIAMONDS, HEARTS, SPADES}; /*Createanother enumeration for the words that represent card point-valuenames (TWO, THREE, and the rest of the number cards through TEN, then JACK,QUEEN, KING, and ACE). */ enum pointValue {TWO=2, THREE, FOUR, FIVE,SIX,SEVEN,EIGHT,NINE,TEN, JACK, QUEEN, KING, ACE}; intmain() { string suitsName[]={"CLUBS","DIAMONDS", "HEARTS", "SPADES"}; string pointValueName[]={"TWO","THREE", "FOUR", "FIVE","SIX", "SEVEN","EIGHT","NINE","TEN", "JACK", "QUEEN", "KING", "ACE"}; // int i,j; int i,j; for(i=CLUBS;i<=SPADES; i++) { for( j=TWO;j<=ACE;j++) cout<<suitsName[i-CLUBS]<<""<<pointValueName[j-TWO]<<"; "; cout<<endl; } // cout << "Hello world!"<< endl; return 0; }
Comments
Leave a comment