Well, well, afraid you're going to be asked to explain your code to your instructor? Or do you have to turn in a written explanation/description of it with the code?
In any case, if you had done your assignment, rather than copying it, you would probably understand it.
P.S. Whether any of the above is true, or not, don't bother protesting, as nobody here is going to believe it. We see far to many "do my assignment for me" requests to believe that you "got this from a friend" for anything other than a homework assignment.
well, i'm new in java.
he explained some like this.
its a final variable which is String[] numbers and String[] tens.
static it is executed according to its appearance.
correct?
private static final String[] numbers = {
"zero","one","two","three","four","five","six",
"seven","eight","nine","ten","eleven","twelve",
"thirteen","fourteen","fifteen","sixteen","seventeen",
"eighteen","nineteen"};
private static final String[] tens = {
"","teen","twenty","thirty","fourty","fifty",
"sixty","seventy","eighty","ninety"};
here's a static initializers which being executed in order.
right?
public static String makeWord(long number){
String s = "";
if(number<0){
s="negative ";
number*=-1;
}
s+=toWord(number);
s = s.replace("-zero","");
return s;
}//end of makeWord
private static String toWord(long number){
if(number>=1000000000){
return toWord(number/1000000000)+"-billion-"+toWord(number%1000000000);
}
else if(number>=1000000){
return toWord(number/1000000)+"-million-"+toWord(number%1000000);
}
else if(number>=1000){
return "" +toWord(number/1000)+"-thousand-"+toWord(number%1000);
}
else if(number>=100){
return numbers[(int)number/100] +"-hundred-"+toWord((long)number%(long)100);
}
else if(number>=20){
return tens[(int)number/10] + "-" + toWord(number%10);
}
else if(number>18){
return numbers[(int)number%10]+"teen";
}
else{
return numbers[(int)number];
}
}//end of toWord
kinda confused.