Solved

How to use Java to convert numbers to words.

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
by zero exception 10 83
going to wrong jsp page 2 70
Need Help! Getting a syntax error and don't understand why 3 56
Selenium findElement(By.classname  identifier 15 37
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

752 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