Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This programming assignment and the next one (Program 3) will implement a simple

ID: 3648798 • Letter: T

Question

This programming assignment and the next one (Program 3) will implement a simple Black Jack game using C + + object oriented constructs. The first task is to implement the function that will print the value of a card, such as 'King of Spades' or '2 of Hearts'. For this assignment all the cards will be represented by a number between 1 and 52. The first 13 cards will be Clubs, the next 13 will be Diamonds the next 13 would be the King of Clubs and card 27 would be the Ace of Hearts and so. Converting from a number between 1 & 52 can be computed as follows: If x is a number between 1 & 52 then To determine the suit use y = x/13, If y is 0 then the card is a Club, if y = 2 then the card is a Diamond and so on. To determine the number of the card use y = x % 13. If y = 0 then the card is an Ace, If y = 1 then the card is a 2 and so on. Be sure to convert the number for face cards to the name of the card. For example, 13 is the king. Your main function should loop asking the user to provide a number between 1 and 52 and then print the card value. Be sure and make your output readable. Put headings where needed and use blank lines to delineate between each input/output.

Explanation / Answer

please rate - thanks

#include <iostream>
using namespace std;
void printcard(int);
int main()
{int n;
cout<<"Enter card number(1-52) anything else to exit: ";
cin>>n;
while(n>0&&n<53)
     {printcard(n);
     cout<<"Enter card number(1-52) anything else to exit: ";
     cin>>n;
     }

return 0;
}
void printcard(int n)
{int suit,card;
n--;
string suits[4]={"clubs","diamonds","hearts","spades",};
string cards[13]={"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"};
suit=n/13;
card=n%13;
cout<<"card "<<n<<" is the "<<cards[card]<<" of "<<suits[suit]<<endl<<endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote