The BaseTenHelperMethods class could have been just arrays/dictionaries inside the Translator however I felt since their output doesn't rely on any context, they have the option to be reused if they were public methods. This could then be inherited to provide an alternative output for currency? Alternatively my class could possibly be expanded upon by converting it to an abstract class with an abstract GetOutput() method. However I didn't like that this would then tie the implementation to the output. This could has been written as a single static method and just working through the number one unit at a time, modifying the return string as it progresses. The parser then just calls itself recursively to break the number down into these thousands components and return the number as its BaseTen chunks of thousand. This code can then live completely free of the Parser and still return a correct result (single/multi-threaded, multi-device etc). This group can then be given a token for which 'thousands' block it is to call the BaseTenHelperMethods.GetBaseTenName() method to get the string representation name. When split into thousands, if the first number exists it will always semantically be n 'Hundred' and then you can just calculate the hundreds & tens remainder. This routine has been designed to try and break up a double into it's base10 thousands components. This would then already allow up to a double.double return. Expanding this would just involve adding more base10 results to the BaseTenHelperMethods.GetBaseTenName function and a small modification to the constructor to accept 2 doubles (whole and fractional) as an input. The class stores and constructs the result of the whole and fractional portions of the number seperately. However the internals of the routine could be very easily adjusted to support larger. NET Core 3.1 MVC has been used.Ĭurrently the application has been restricted to a 15 digit number to keep the application simple and prove a proof of concept. NET 6's minimal API's would be a perfect use case for such a small web application however this is not currently in stable release so. This routine will represent these as the first case. 1600 Could be written as both one thousand six hundred and sixteen hundred. This also misses a common representation of four digit numbers. This isn't perfectly ideal as people may have a different idea on when/if and should be used to connect groups of numbers. This routine will only return a single representation of a number. For this reason I have designed the routine to just return language representation of the decimal itself (one tenth etc.) Ideally this would be clarified before continuing as currency has completely different limitations to 'numerical input'. The design criteria just requires to to convert from a number into words, however the example given returns it in a basic currency. Output: “ONE HUNDRED AND TWENTY-THREE DOLLARS AND FORTY-FIVE CENTS” Design Considerations Please develop a web page featuring a web server routine that converts numerical input into words and passes these words as a string output parameter. Navigate to and type away :) Design Criteria Test your skills: Number to Words Web Page Once the runtime is installed just dotnet run inside of the Translator.WebMVC folder.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |