Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LastDigitOfNumber
- {
- class LastDigitOfNumber
- {
- static void Main()
- {
- Console.WriteLine("Please enter a number:");
- int number = int.Parse(Console.ReadLine());
- string s = GetLastDigitOfANumber(number);
- Console.WriteLine(s);
- }
- static string GetLastDigitOfANumber(int inputNum)
- {
- int lastDigit = inputNum % 10;
- string last = "";
- switch(lastDigit)
- {
- case 1:
- last = "one";
- break;
- case 2:
- last = "two";
- break;
- case 3:
- last = "three";
- break;
- case 4:
- last = "four";
- break;
- case 5:
- last = "five";
- break;
- case 6:
- last = "six";
- break;
- case 7:
- last = "seven";
- break;
- case 8:
- last = "eight";
- break;
- case 9:
- last = "nine";
- break;
- }
- return last;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement