number change to words

closed account (o2TCpfjN)
i need to create a program that will convert numbers into words...
example input: 1
output: one

50 inputs...

but need to use switch and cannot use if/else
geez, what a sadistic program.

If you want to do this and make it pretty, you'll come up with some nice ways of re-using different cases for once you get into double-digits.

If you want to strongarm it, all you need is a switch and 50 case statements.

Just load the input into an integer, then do a switch. Here's an example:
http://www.cplusplus.com/doc/tutorial/control.html
It's at the bottom of the page. Do NOT forget to put in the break; for each case otherwise it will fall through and print everything after that case.

Good luck, if you need help post again with your code.
closed account (o2TCpfjN)
50 case is not allow
how to use about 30 case to finish this???
You need multiple switch statements.
One for first digit
One for second digit where first digit is 2-5
One for where fist digit is 0-1
take a look at where you can re-use switch statements you've already created.

For instance

twenty-one is a combination of printing twenty, and then one. Both of which you already have from other cases. So instead of a case for 21,22,23,24,25. You can combine your case for 20, and then for one, two, three, four, five, ect.
Topic archived. No new replies allowed.