C++ Pointers & Classes: Translating $0-9999

  • Context: C/C++ 
  • Thread starter Thread starter ladykaelin
  • Start date Start date
  • Tags Tags
    Classes Pointers
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
ladykaelin
Messages
1
Reaction score
0
Hi I am new using pointers and i am having a hard time trying to figure out how to write a program in c++ using pointers and classes. The program can be used to translate whole dollar amounts in the range 0 through 9999 into an English description of the number. For example, the number 713 would be translated into the string seven hunde thirteen, and 8203 would be translated into eight thousand hundred three, etc.,

Any idea is helpful. Thanks!
 
Physics news on Phys.org
Are you looking for help on the use of c++ pointers/classes, or on the algorithm of translating numbers to text strings?

For help on pointers, try http://www.cplusplus.com/doc/tutorial/pointers/

For help on classes, try http://www.cplusplus.com/doc/tutorial/classes/

Regarding the application, I don't think there is anything particularly clever that can be done other than a series of conditional statements. Some time ago, I made an excel macro to prepare text like that for cheque printing. The general idea was to split the number into chunks of three orders of magnitude (eg. the "millions", "thousands" and "ones").

With that, each three-digit chunk was processed by my algorithm, which appended to a string based on the contents of that chunk. The whole thing was stitched together in the end, where proper place holders were stuck in.
 
Last edited by a moderator: