Jumping into C++ chapter 7 help
Hello, I'm working through the jumping into C++ beginner ebook and I'm completely stumped on the practice problems for chapter seven. The first one ask to implement source code that will take in numbers between -2billion and 2 billion in number form and print it out in word form (ie 1204 is one thousand two hundred four). These are the steps it says you should do:
1) Break the number up into chunks of three digits
2) For each three-digit chunk, compute the text; append the magnitude of that chunk; append the
chunks together
3) To compute the text of a three-digit chunk, compute the number of hundreds, and convert that
one-digit number to text, and add “hundreds”, appending the text of the two-digit chunk
4) To compute the text of a two-digit chunk, if it’s less than 20, look it up; if it’s greater than 20,
compute the number of tens, and look up the word, and append the text of the one-digit
number
I don't understand how I can seperate the number i input into chunks of three though, can anyone help me understand this? I have gotten a program to work that will give me the numbers 0-19 in word form if I input them just by using a series of 20 different if statements like:
if (number == 12)
cout << "The number " << number << " is twelve.";
but once I start getting into the numbers past nineteen and there are patterns that I can use to efficiently change it into words I am just completely stumped how to implement that... Any help would be appreciated, please let me know if you need anything to be clarified if I didn't make sense.