Solved

How to use Java to convert numbers to words.

Posted on 2003-12-02
4
638 Views
Last Modified: 2012-05-04
Hi, I'm trying to write a java code to convert numbers to words, but I somewhat can't find a way to finish it. The application needs two dialog box. The first one ask the user to enter a 4 digit number. The second one shows the result (ex. 123 is equal to one hundred twenty three). Below is what I have so far. I have put the part that I don't how to finish in the notation. Could you guys please give me a hand, or referr me to some similar example? Thank you very much.


import javax.swing.JOptionPane

public class NumberConverterApp {
    public static void main (String[] args){

        String choice="";
        while (!(choice.equalsIgnoreCase("X"))){
              //[how to get and parse input?]
               String[] units = {"one, "two", "three, "four", "five", "six", "seven", "eight", "nine");
               String[] teens{"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
               String[] tens ={"twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"};
               String word = "";
               if (num.length == 4){
                     //[how to convert to words?]
               }
               choice = JOptionPane.showInputDialog(numbers + " is equal to \n"
                          + word + "\n Press enter to continue or 'x' to exit.");
          }//end while
          System.exit(0);
       }
   }




0
Comment
Question by:tan8888
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 300 total points
ID: 9864877
0
 

Author Comment

by:tan8888
ID: 9864911
Thanks a lot for the links. But it would be a lot helpful if I can get a few more tips or examples in order to solve the probelm. Thank you.
0
 
LVL 92

Expert Comment

by:objects
ID: 9864941
they both contain working examples to convert numbers into words, what exactly do you need help with?
0
 
LVL 92

Expert Comment

by:objects
ID: 9869350
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question