Solved

How to use Java to convert numbers to words.

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bigHeights  challenge 13 56
where is session ID cache stored 1 40
@SBGen Method 3 25
Strange loading of website behaviour 3 23
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now