Results 1 to 2 of 2
  1. #1
    kazumahits is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default Anyone can explain this?

    Java Code:
    import javax.swing.JOptionPane;
    public class jop {
    
        public static void main(String[] args) {
    
        String i1 =
            JOptionPane.showInputDialog( "Enter first Number" );
        String i2 =
            JOptionPane.showInputDialog( "Enter second Number" );
        String i3 =
            JOptionPane.showInputDialog( "Menu \n1:Addition\n2:Subtraction\n3:Multiplication\n4:Division" );
    
        int n1 = Integer.parseInt( i1 );
        int n2 = Integer.parseInt( i2 );
        int n3 = Integer.parseInt( i3 );
    
        int a1 = n1 + n2;
        int a2 = n1 - n2;
        int a3 = n1 * n2;
        int a4 = n1 / n2;
    
        if (n3 == 1) {
            JOptionPane.showMessageDialog( null, "The sum is " + a1,
    "Sum of Two Integers", JOptionPane.PLAIN_MESSAGE );
        }
        else if (n3 == 2) {
            JOptionPane.showMessageDialog( null, "The difference is " + a2,
    "Difference of Two Integers", JOptionPane.PLAIN_MESSAGE );
        }
        else if (n3 == 3) {
            JOptionPane.showMessageDialog( null, "The Product is " + a3,
    "Product of Two Integers", JOptionPane.PLAIN_MESSAGE );
        }
        else if (n3 == 4) {
            JOptionPane.showMessageDialog( null, "The Quotient is " + a4,
    "Quotient of Two Integers", JOptionPane.PLAIN_MESSAGE );
    
    
        } else {
    JOptionPane.showMessageDialog(null, "Please Enter a Valid Number");
    }
    
        }
    }
    i cant explain this... please help me...

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    This has got to be a homework dump, this program is so simple to understand. Try compiling and running it, see if that helps you explain it.

Similar Threads

  1. Replies: 2
    Last Post: 12-13-2010, 02:34 PM
  2. Replies: 3
    Last Post: 12-13-2010, 08:22 AM
  3. Can somebody explain me this plz
    By ccie007 in forum New To Java
    Replies: 4
    Last Post: 05-20-2010, 08:47 PM
  4. Can someone explain why the red text?
    By 357mag in forum JCreator
    Replies: 0
    Last Post: 05-08-2010, 05:29 AM
  5. Can someone explain why...
    By Krooger in forum AWT / Swing
    Replies: 1
    Last Post: 11-19-2009, 07:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •