ellapt

T9.3.LastDigitToEnglishWord

Jan 19th, 2013
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. class LastDigitToEnglishWord
  4. {
  5. static string LastDigitToWord(int digit)
  6. {
  7. string[] digits = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
  8. digit=digit%10;
  9. string digitToString=digits[digit];
  10. return digitToString;
  11. }
  12.  
  13. static void Main()
  14. {
  15. string lastDigit;
  16. int number;
  17.  
  18. Console.Write("Enter an integer number: ");
  19. number = int.Parse(Console.ReadLine());
  20. lastDigit = LastDigitToWord(number);
  21. Console.WriteLine("The last digit of the number {0} is: {1}", number, lastDigit);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment