Skip to content

Calculator: Number to Words Application that will output any number to words

Notifications You must be signed in to change notification settings

casterfile/Calculator-Number-to-Words

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Calculator-Number-to-Words

Developer: Anthony A. Castor

This Source does not give any warranty please use at your own risk

Calculator: Number to Words Application that will output any number to words

This application is free of virus or malware

Software Requirment

Unity 5.6
Unity C#

Online Portfolio

Distribution itch(Web and Desktop): https://goo.gl/Wq1nuD
Distribution Google Play: https://goo.gl/uKIIr4
Distribution Itunes AppStore: https://goo.gl/54yJPi
Distribution Amazon Store: https://goo.gl/RUp1Od
Distribution Windows Store: https://goo.gl/rCxsH6 (No Direct link to Dev Page)
Distribution WearVR: https://goo.gl/y0X1nR (No Direct link to Dev Page)

More Information and Demo Videos

Facebook: https://goo.gl/vvDSIL
Linkedin: https://goo.gl/c9Fh6n
YouTube: https://goo.gl/BFZ7C5
StackOverFlow: https://goo.gl/J1hFqL
Github: https://goo.gl/jPHFPe

Application Functions

1) Calculator
2) Convert Number into Word

Source Code

//Calulation to Words
public string DecimalToWords(decimal number)
{
	if (number == 0)
		return "zero";

	if (number < 0)
		return "minus " + DecimalToWords(Math.Abs(number));

	string words = "";

	long intPortion = (long)number;
	decimal fraction = (number - intPortion)*100;
	long decPortion = (long)fraction;

	words = NumberToWords(intPortion);
	if (decPortion > 0)
	{
		words += " and ";
		words += NumberToWords(decPortion);
	}
	return words;
}

public static string NumberToWords(long number)
{
	if (number == 0)
		return "zero";

	if (number < 0)
		return "minus " + NumberToWords(Math.Abs(number));

	string words = "";

	if ((number / 1000000000000) > 0)
	{
		words += NumberToWords(number / 1000000000000) + " trillion ";
		number %= 1000000000000;
	}

	if ((number / 1000000000) > 0)
	{
		words += NumberToWords(number / 1000000000) + " billion ";
		number %= 1000000000;
	}

	if ((number / 1000000) > 0)
	{
		words += NumberToWords(number / 1000000) + " million ";
		number %= 1000000;
	}

	if ((number / 1000) > 0)
	{
		words += NumberToWords(number / 1000) + " thousand ";
		number %= 1000;
	}

	if ((number / 100) > 0)
	{
		words += NumberToWords(number / 100) + " hundred ";
		number %= 100;
	}

	if (number > 0)
	{
		if (words != "")
			words += "and ";

		var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
		var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

		if (number < 20)
			words += unitsMap[number];
		else
		{
			words += tensMap[number / 10];
			if ((number % 10) > 0)
				words += "-" + unitsMap[number % 10];
		}
	}

	return words;
}

Screenshot

alt text alt text alt text

About

Calculator: Number to Words Application that will output any number to words

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages