Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace avstn.moneySeparator
- {
- class Program
- {
- private static void Main(string[] args)
- {
- int numb;
- do
- {
- Console.WriteLine("Enter number");
- numb = int.Parse(Console.ReadLine());
- Console.WriteLine("Result: {0} \n", separateMoney(numb, '.'));
- }
- while (numb > 0);
- }
- private static string separateMoney(int numb, char sepSymb)
- {
- string money = numb.ToString();
- int blLen = 3;
- if (money.Length <= blLen)
- return money;
- string response = string.Empty;
- do
- {
- string a = money.Substring(money.Length - blLen, blLen);
- money = money.Substring(0, money.Length - blLen);
- response = string.Format("{0}{1}{2}", sepSymb, a, response);
- }
- while (money.Length > blLen);
- return string.Format("{0}{1}", money, response);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement