Solved

How to use Java to convert numbers to words.

Posted on 2003-12-02
4
618 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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Arrays.asList  VS  ArrayList 4 71
more than one jdk and one jre 1 50
jboss wildfly 10.1 10 233
JavaFX TableView not displaying correctly 3 58
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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

829 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