Ok, so i have a few questions. There's something wrong with my validation loop because if you enter anything that isn't an int (anything with decimal places), it goes into an infinite loop; However, when there is no decimal places it does as intended. To add to this, i need to get this program to print out a string formatted dollar amount, just as you would on a check.
For example, lets say i had $876.65.
it needs to say, "you have eight hundred and seventy six dollars and 65 cents".
i need to do all this using arrays. i can't use for loops.
If I pay myself 12.00 it's OK. But not if I pay myself 1234.50; then it goes ape.
I think you need to rethink how you deal with reading the wage. While you tell people 999.99 is the most they can enter, you do nothing to handle the case if they enter a higher/longer number. As you're extracting only 6 chars from cin, if they enter more that that, cin's fail bit will be set.
Try adding the following after you get the wage the first time.
1 2 3 4 5 6 7
if(cin.fail())
{
cerr << "fail!" << endl; // just for illustration
cin.clear();
cin.ignore(std::numeric_limits<streamsize>::max(), '\n');
// std::numeric_limits is from <limits>
}
If that works, you should factor out the code to get the wage -- inc the error handling -- into a helper function.
Note that this code does not attempt to handle all error conditions. For example, if I enter 1.w.h.a.t as my wage, I see "fail" but am then paid $1. Ideally you'd check the wage string before converting it.
now, for my other problem. I know i need to set up some string arrays in order to display out a word form of the number the user enters. However, i do not know at all how to go about doing this. See my example at the top. Can anyone help?