Advertisement
AnitaN

05.ConditionalStatementsHomework/08.DigitAsWord

Mar 29th, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. //Problem 8. Digit as Word
  2. //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.
  3.  
  4. using System;
  5.  
  6. class DigitAsWord
  7. {
  8.     static void Main()
  9.     {
  10.         Console.Write("Please, enter some number:");
  11.         int number = int.Parse(Console.ReadLine());
  12.         switch (number)
  13.         {
  14.             case 0:
  15.                 Console.WriteLine("zero");
  16.                 break;
  17.             case 1:
  18.                 Console.WriteLine("one");
  19.                 break;
  20.             case 2:
  21.                 Console.WriteLine("two");
  22.                 break;
  23.             case 3:
  24.                 Console.WriteLine("three");
  25.                 break;
  26.             case 4:
  27.                 Console.WriteLine("four");
  28.                 break;
  29.             case 5:
  30.                 Console.WriteLine("five");
  31.                 break;
  32.             case 6:
  33.                 Console.WriteLine("six");
  34.                 break;
  35.             case 7:
  36.                 Console.WriteLine("seven");
  37.                 break;
  38.             case 8:
  39.                 Console.WriteLine("eight");
  40.                 break;
  41.             case 9:
  42.                 Console.WriteLine("nine");
  43.                 break;
  44.             default:
  45.                 Console.WriteLine("It's not a digit between 0 to 9");
  46.                 break;
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement