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

  • Context: C/C++ 
  • Thread starter Thread starter ladykaelin
  • Start date Start date
  • Tags Tags
    Classes Pointers
Click For Summary
SUMMARY

The discussion focuses on creating a C++ program that translates dollar amounts from 0 to 9999 into English text using pointers and classes. Participants suggest using a series of conditional statements to break down the number into chunks, such as millions, thousands, and ones, and then process each chunk to form the final string. Resources for understanding C++ pointers and classes are provided, specifically linking to tutorials on cplusplus.com. The approach emphasizes the importance of structuring the program to handle different segments of the number effectively.

PREREQUISITES
  • C++ programming knowledge
  • Understanding of pointers in C++
  • Familiarity with classes in C++
  • Basic algorithm design for number translation
NEXT STEPS
  • Research C++ pointer usage in depth
  • Learn about class design in C++ for better code organization
  • Study algorithms for number-to-text conversion
  • Explore conditional statements and their applications in C++
USEFUL FOR

Beginner to intermediate C++ programmers, software developers interested in algorithm design, and anyone looking to enhance their understanding of pointers and classes in practical applications.

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!
 
Technology 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:

Similar threads

  • · Replies 17 ·
Replies
17
Views
4K
Replies
5
Views
2K
Replies
5
Views
2K
  • · Replies 23 ·
Replies
23
Views
2K
  • · Replies 31 ·
2
Replies
31
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 7 ·
Replies
7
Views
12K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 34 ·
2
Replies
34
Views
4K