ntodorova

11_Cards

Nov 19th, 2012
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2.  
  3. /*
  4.  * 11. Write a program that prints all possible cards from a standard deck of
  5.  * 52 cards (without jokers). The cards should be printed with their English names.
  6.  * Use nested for loops and switch-case.
  7.  */
  8. class Cards
  9. {
  10.     static void Main()
  11.     {
  12.         string[] cards = {"Two of", "Three of", "Four of", "Five of", "Six of", "Seven of",
  13.                           "Eight of", "Nine of", "Ten of", "King of", "Queen of", "Knave of", "Ace of"};
  14.  
  15.         for (int i = 0; i < cards.Length; i++)
  16.         {
  17.             for (int j = 1; j < 5; j++)
  18.             {
  19.                 Console.Write(cards[i]);
  20.  
  21.                 switch (j)
  22.                 {
  23.                     case 1:
  24.                         Console.WriteLine(" Spades");
  25.                         break;
  26.  
  27.                     case 2:
  28.                         Console.WriteLine(" Hearts");
  29.                         break;
  30.  
  31.                     case 3:
  32.                         Console.WriteLine(" Diamonds");
  33.                         break;
  34.  
  35.                     case 4:
  36.                         Console.WriteLine(" Clubs");
  37.                         break;
  38.  
  39.                     default:
  40.                         Console.WriteLine("Error!");
  41.                         break;
  42.                 }
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment