View Single Post
  #5 (permalink)  
Old 10-08-2008, 07:53 AM
Eranga's Avatar
Eranga Eranga is offline
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Here is much better code segment. Write it just for fun. Try to learn something on that pal, but I'm not superior on Java.

Code:
import javax.swing.JOptionPane;

public class study2 {

    public static void main(String[] args) {
        String temp1 = null , temp2 = null;
        int num1 = 0 , num2 = 0, max = 0;
        int ret = 0;
        
        inner: do {
            try {
                temp1 = JOptionPane.showInputDialog("The First Number is:");
                num1 = Integer.parseInt(temp1);

                temp2 = JOptionPane.showInputDialog("The Second Number is:");
                num2 = Integer.parseInt(temp2);
            }
            catch(NumberFormatException ex) {
                JOptionPane.showMessageDialog(null, "Invalid input");
                continue inner;
            }
            if (num1 > num2)
                max = num1;
            else 
                max = num2;

            JOptionPane.showMessageDialog(null,"The Maximum is " +max);
            ret = JOptionPane.showConfirmDialog(null, "Continue?", "More", 
                    JOptionPane.YES_NO_OPTION , JOptionPane.INFORMATION_MESSAGE);

        } while(ret == JOptionPane.YES_OPTION);
    }

}
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Reply With Quote