Results 1 to 2 of 2
Thread: Anyone can explain this?
- 03-08-2011, 01:54 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
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"); } } }
- 03-08-2011, 02:03 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,068
- Blog Entries
- 3
- Rep Power
- 15
Similar Threads
-
Please Explain me how i got this output.. I am new to java .. so please Explain me...
By vicky82 in forum New To JavaReplies: 2Last Post: 12-13-2010, 01:34 PM -
Please Explain me how i got this output.. I am new to java .. so please Explain me...
By vicky82 in forum New To JavaReplies: 3Last Post: 12-13-2010, 07:22 AM -
Can somebody explain me this plz
By ccie007 in forum New To JavaReplies: 4Last Post: 05-20-2010, 07:47 PM -
Can someone explain why the red text?
By 357mag in forum JCreatorReplies: 0Last Post: 05-08-2010, 04:29 AM -
Can someone explain why...
By Krooger in forum AWT / SwingReplies: 1Last Post: 11-19-2009, 06:59 AM
Bookmarks