I'm trying to invoke the "ToEnglish" method in the main method so that my program will output the four-digit integer in English words. For example if I enter the integer 4321, I want my program to output Four Three Two One.
Any help would be much appreciated!
You need to define a static method oneDigit(int) in your class. And, because this method is a part of the ToEnglish class, as is main(), you can simplify the calls to "oneDigit(n1);", that is, you don't need the "ToEnglish." in front of it.
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
posted 1 year ago
this is my updated version. I'm still unsure how to properly invoke the oneDigit method so that my output will print "Four Three Two One"
oneDigit() can also be implemented with one statement. Since you have a number, you can use that number to get a corresponding element in an array. Since you have a known finite set of corresponding strings, you can use a statically declared array.
Practice only makes habit, only perfect practice makes perfect.
Practice mindfully by doing the right things and doing things right.— Junilu