Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- //Declaration
- char suite = 'Z';
- long int rank = 0;
- //Input & Process
- printf("Please input the letter of the suite of the card.\n");
- printf("Either (H)earts (D)iamonds, (C)lubs, or (S)pades.\n");
- scanf("%c", &suite);
- printf("Please input the number of the card, \n with 11 being a Jack, 12 a Queen, 13 a King, and 14 a Ace \n");
- scanf("%d", &rank);
- //Process
- switch(rank)
- {
- case 14:
- {
- if(suite == 'H')
- printf("Your card is the Ace of Hearts!");
- else if(suite == 'C')
- printf("Your card is the Ace of Clubs!");
- else if(suite == 'D')
- printf("Your card is the Ace of Diamonds!");
- else
- printf("Your card is the Ace of Spades!");
- }
- case 13:
- {
- if (suite == 'H')
- printf("Your card is the King of Hearts!");
- else if(suite == 'C')
- printf("Your card is the King of Clubs!");
- else if(suite == 'D')
- printf("Your card is the King of Diamonds!");
- else
- printf("Your card is the King of Spades!");
- }
- case 12:
- {
- if (suite == 'H')
- printf("Your card is the Queen of Hearts!");
- else if(suite == 'C')
- printf("Your card is the Queen of Clubs!");
- else if(suite == 'D')
- printf("Your card is the Queen of Diamonds!");
- else
- printf("Your card is the Queen of Spades!");
- }
- case 11:
- {
- if (suite == 'H')
- printf("Your card is the Jack of Hearts!");
- else if(suite == 'C')
- printf("Your card is the Jack of Clubs!");
- else if(suite == 'D')
- printf("Your card is the Jack of Diamonds!");
- else
- printf("Your card is the Jack of Spades!");
- }
- default:
- {
- if (suite == 'H')
- printf("Your card is the %d of Hearts!", rank);
- else if(suite == 'C')
- printf("Your card is the %d of Clubs!", rank);
- else if(suite == 'D')
- printf("Your card is the %d of Diamonds!", rank);
- else
- printf("Your card is the %d of Spades!", rank);
- }
- }
- /*
- Test Plan
- Case 1
- Input=12H
- Expected Output=Queen of hearts
- Case 2
- Input=5C
- Expected Output=5 of Clubs
- Case 3
- Input=14S
- Expected Output=Ace of spades
- */
- sleep(1000);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement