Advertisement
VyaraG

DigitAsWord

Nov 29th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2.  
  3. //Write a program that asks for a digit (0-9), and depending on the input, shows the digit as a word (in English). Print “not a digit” in case of invalid inut. Use a switch statement.
  4.  
  5. class DigitAsWord
  6. {
  7.     static void Main()
  8.     {
  9.         Console.Write("Enter a digit (0-9) to see the word in English: ");
  10.         string digitAsWord = Console.ReadLine();
  11.         switch (digitAsWord)
  12.         {
  13.             case "1":
  14.                 Console.WriteLine("one");
  15.                 break;
  16.             case "2":
  17.                 Console.WriteLine("two");
  18.                 break;
  19.             case "3":
  20.                 Console.WriteLine("three");
  21.                 break;
  22.             case "4":
  23.                 Console.WriteLine("four");
  24.                 break;
  25.             case "5":
  26.                 Console.WriteLine("five");
  27.                 break;
  28.             case"6":
  29.                 Console.WriteLine("six");
  30.                 break;
  31.             case "7":
  32.                 Console.WriteLine("seven");
  33.                 break;
  34.             case "8":
  35.                 Console.WriteLine("eight");
  36.                 break;
  37.             case "9":
  38.                 Console.WriteLine("nine");
  39.                 break;
  40.             case "0":
  41.                 Console.WriteLine("zero");
  42.                 break;
  43.             default: Console.WriteLine("Not a digit!");
  44.                 break;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement