guys i cant understand or even think of how i can start my program. I should input a number and convert it in words ..its so hard for me to understand how to do this because like what i have said im NEW here thank you
so i need to convert a number into words from "1" to "10,001" it will take me months if i will type it over and over again so is there any other way? this is what i did :

String words;
	     int num = Integer.parseInt(JOptionPane.showInputDialog("Enter Number"));
	      		       
	     if (num == 1) {
			            words = "one";
			        } else if (num == 2) {
			            words = "two";
			        } else if (num == 3) {
			            words = "three";
			        } else if (num == 4) {
			            words = "four";
			        } else if (num == 5) {
			            words = "five";
			        } else if (num == 6) {
			            words = "six";
			        } else if (num == 7) {
			            words = "seven";
			        } 
			        
			        else {
			            words = "unidentified";
			        }
			        JOptionPane.showMessageDialog(null, "Translation in words = " + words);
	}

}

thank you guys hope u can help me.

Edited 4 Years Ago by peter_budo: Keep It Clear - Do use code tags when posting any code

you may be literally new to Java, but you are also literally ignoring help that's been given in the other thread about this application.
have you changed anything yet? implemented the arrays as suggested?
don't start a new thread, continue in the other one with the hints you were given, or pretty soon you'll find not many members will be as willing to help any more.

you may be literally new to Java, but you are also literally ignoring help that's been given in the other thread about this application.
have you changed anything yet? implemented the arrays as suggested?
don't start a new thread, continue in the other one with the hints you were given, or pretty soon you'll find not many members will be as willing to help any more.

sir i did..what i did is this:

 String[] arrWords = {"one","two","three","four"};

         int arrNumbers= Integer.parseInt(JOptionPane.showInputDialog("Enter Number"));

        JOptionPane.showMessageDialog( null,"translation"+arrWords);


    }

}

and it does have some errors please dont laugh at me with my errors...ive been really trying to figure out how and i appreciate ur help...thank you sir ur suggestions are really helpful and i also searched on google some of the things that u said like that array but thats what i get. im sorry sir if im slow :(

Edited 3 Years Ago by pyTony: fixed formating

if you try to print an object (an array is always an object) you'll only print a reference to that object, in the form of [I@3e25a5, so you may think that it is an error, but it isn't.
first thing you do, you read your number.
after which, you find in arrNumbers the index of that number
then, you print the word that can be found on the same index in arrWords.

do you know how to use the index of an array?

Please search forum this was already discussed multiple times (last time no longer then few weeks). Secondly use of if/else for every check is mad house use array

if you try to print an object (an array is always an object) you'll only print a reference to that object, in the form of [I@3e25a5, so you may think that it is an error, but it isn't.
first thing you do, you read your number.
after which, you find in arrNumbers the index of that number
then, you print the word that can be found on the same index in arrWords.

do you know how to use the index of an array?

no sir i dont have any idea on how to use array and index because we are still on our discussion on if else statements .. :( so i dont know what that is im sorry :(

@Ms New to Java
1)Multiposting not welcome!
2) Use code tags when posting any code such as [code] YOUR CODE HERE [/code]
3) Thread closed. For further discussion follow this thread

This article has been dead for over six months. Start a new discussion instead.