I don't understand why he writes that line?
Why does he have to create an instance of Numwords?
One can delete this line and still the program runs smoothly. Can you
give me the link where he explains this or if it doesn't exist, try to
explain  this for me?

Thanks in advance
-Halli

import javax.swing.JOptionPane;

public class NumWords {

    /** Creates a new instance of NumWords */
    public NumWords() {
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String msg = "";
        int input = 0;

        // Get the input string
        input = Integer.parseInt(JOptionPane.showInputDialog
                ("Enter number between 1 to 10"));

        // Set msg variable to the string equivalent of input
        if(input == 1)        msg = "one";
        else if(input == 2)    msg = "two";
        else if(input == 3)    msg = "three";
        else if(input == 4)    msg = "four";
        else if(input == 5)    msg = "five";
        else if(input == 6)    msg = "six";
        else if(input == 7)    msg = "seven";
        else if(input == 8)    msg = "eight";
        else if(input == 9)    msg = "nine";
        else if(input == 10)    msg = "ten";
        else            msg = "Invalid number";

        // Display the number in words if with in range
        JOptionPane.showMessageDialog(null,msg);
    }
}

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to