Amount to Words Converter

Long-time ago I created a program on how to convert an amount in number to words. And here are the rules: You need to create a form with an ...


Long-time ago I created a program on how to convert an amount in number to words. And here are the rules:

You need to create a form with an edit box a button and a memo. These are not a part of the test but present the solution in a simple way and allow you to test functionality. In the edit box the user should be able to enter a number less than 2 billion with exactly 2 decimal places with nothing but numbers and a decimal point (no commas).

Upon clicking the “Convert” button the program will fill the memo with the English words that express that number as a string of words (dollars and cents). The program should encode words exactly as you would say them in English when reading out the monetary amount.

Example 1:
If the user enters 1357256.32 then the program would convert that to “one million, three hundred and fifty seven thousand, two hundred and fifty six DOLLARS AND thirty two CENTS”.

Example 2:
If the user enters 1.01 then the program would convert that to “one DOLLAR AND one CENT”.

Example 3:
If the user enters 102030405.06 then the program would convert that to “one hundred and two million, thirty thousand, four hundred and five DOLLARS AND six CENTS”.

Example 4:
If the user enters 1000000000.99 then the program would convert that to “one billion DOLLARS AND ninety nine CENTS”.

Hints:
No validation of input is required: the test assumes the user will type numbers without commas and within the limits of this program’s requirements (less than 2 billion and with exactly 2 decimal places always)

Any number less than 2 billion should be allowed but in fact, it's easy once correctly solved that trillions are also added –extending to trillions is not required, this is a hint only.

The solution could be done in a number of ways but needs to be elegant.

Loops or recursion are often seen in the solution - one of these is possibly smaller in size. Smaller/more elegant is better.

It is important to note the way we comma separate numbers eg 1,357,256.32 as this represents the 1000 divisor (billion, million, thousand, etc) and the pause in the English spoken numbers. Note the commas are not in the text input

You may assume that the text has at least one integer to the left-hand side of the '.' and that the right-hand side is exactly 2 decimal places. You should code a function or functions that accept INT and return a string by calling it twice something like this: - Words = Int2Words(leftInt) + “DOLLARS AND ”  + Int2Words(rightInt) + “ CENTS”.

Zero should work as an input on either or both sides of the decimal.

There are language rules in English regarding speaking words that are not obvious and hard to discover. You should use a range of test numbers from small to large and check them against how you would say them in common speech.

The codes are available here: https://github.com/czetsuya/Amount-to-Words-Converter
CSharp version: https://github.com/czetsuya/Amount-to-Words-Converter-CS

COMMENTS

mas template
Name

amazon,1,angular,8,bigdata,2,business,1,course-spring,27,courses,6,database,4,docker,3,java,50,kafka,1,keycloak,4,microservices,5,mysql,1,neworking,1,nosql,2,php,1,pinned,2,react,3,server management,7,shared drive,1,spring,7,synology,1,troubleshooting,2,web,1,wordpress,1,
ltr
item
toztech: Amount to Words Converter
Amount to Words Converter
https://1.bp.blogspot.com/-nM12Jbn6tgI/XTQlgRYjnSI/AAAAAAAAKlQ/EABRJCnymyMxMFik0I3D8RyHZfGnL4OiQCLcBGAs/s400/CalendarPowerJava.png
https://1.bp.blogspot.com/-nM12Jbn6tgI/XTQlgRYjnSI/AAAAAAAAKlQ/EABRJCnymyMxMFik0I3D8RyHZfGnL4OiQCLcBGAs/s72-c/CalendarPowerJava.png
toztech
https://toztech.blogspot.com/2019/07/amount-to-words-converter.html
https://toztech.blogspot.com/
https://toztech.blogspot.com/
https://toztech.blogspot.com/2019/07/amount-to-words-converter.html
true
2554149350007112447
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content