Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class LastDigitOfIntAsEnglishWord
- {
- static string DigitAsEnglishWord(string digit)
- {
- string lastDigit = digit.Substring(digit.Length-1, 1);//Get the last symbol in the string by making a sustring from the last position
- switch (lastDigit)//Switch the cases
- {
- case "0": { digit = "zero"; } break;
- case "1": { digit = "one"; } break;
- case "2": { digit = "two"; } break;
- case "3": { digit = "three"; } break;
- case "4": { digit = "four"; } break;
- case "5": { digit = "five"; } break;
- case "6": { digit = "six"; } break;
- case "7": { digit = "seven"; } break;
- case "8": { digit = "eight"; } break;
- case "9": { digit = "nine"; } break;
- default: { digit = "Not a digit!"; } break;//If the symbol isn't a digit, print a warning.
- }
- return digit;
- }
- static void Main()
- {
- Console.Write("Please enter an integer number:");
- string inputNum = Console.ReadLine();
- string result = DigitAsEnglishWord(inputNum);
- Console.WriteLine(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement