Advertisement
Zooby4456

C Code Error

Oct 13th, 2014
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.54 KB | None | 0 0
  1. int main()
  2. {
  3.    //Declaration
  4.    char suite = 'Z';
  5.    long int rank = 0;
  6.    //Input & Process
  7.    printf("Please input the letter of the suite of the card.\n");
  8.    printf("Either (H)earts (D)iamonds, (C)lubs, or (S)pades.\n");
  9.    scanf("%c", &suite);
  10.    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");
  11.    scanf("%d", &rank);
  12.  
  13. //Process
  14.    switch(rank)
  15.    {
  16.       case 14:
  17.          {
  18.        if(suite == 'H')
  19.             printf("Your card is the Ace of Hearts!");
  20.        else if(suite == 'C')
  21.             printf("Your card is the Ace of Clubs!");
  22.        else if(suite == 'D')
  23.             printf("Your card is the Ace of Diamonds!");
  24.        else
  25.             printf("Your card is the Ace of Spades!");
  26.          }
  27.       case 13:
  28.          {
  29.          if (suite == 'H')
  30.             printf("Your card is the King of Hearts!");
  31.          else if(suite == 'C')
  32.             printf("Your card is the King of Clubs!");
  33.          else if(suite == 'D')
  34.             printf("Your card is the King of Diamonds!");
  35.          else
  36.             printf("Your card is the King of Spades!");
  37.          }
  38.      
  39.       case 12:
  40.          {
  41.          if (suite == 'H')
  42.             printf("Your card is the Queen of Hearts!");
  43.          else if(suite == 'C')
  44.             printf("Your card is the Queen of Clubs!");
  45.          else if(suite == 'D')
  46.             printf("Your card is the Queen of Diamonds!");
  47.          else
  48.             printf("Your card is the Queen of Spades!");
  49.          }  
  50.       case 11:
  51.          {
  52.          if (suite == 'H')
  53.             printf("Your card is the Jack of Hearts!");
  54.          else if(suite == 'C')
  55.             printf("Your card is the Jack of Clubs!");
  56.          else if(suite == 'D')
  57.             printf("Your card is the Jack of Diamonds!");
  58.          else
  59.             printf("Your card is the Jack of Spades!");
  60.          }
  61.       default:
  62.          {
  63.          if (suite == 'H')
  64.             printf("Your card is the %d of Hearts!", rank);
  65.          else if(suite == 'C')
  66.             printf("Your card is the %d of Clubs!", rank);
  67.          else if(suite == 'D')
  68.             printf("Your card is the %d of Diamonds!", rank);
  69.          else
  70.             printf("Your card is the %d of Spades!", rank);
  71.          }
  72.       }
  73.    
  74. /*
  75.    Test Plan
  76.    Case 1
  77.    Input=12H
  78.    Expected Output=Queen of hearts
  79.    
  80.    Case 2
  81.    Input=5C
  82.    Expected Output=5 of Clubs
  83.    
  84.    Case 3
  85.    Input=14S
  86.    Expected Output=Ace of spades
  87. */
  88.    sleep(1000);
  89.    getch();
  90.    return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement