Operator Example Using GUI (Swing) Input And CLI (io) Input Both
import javax.swing.JOptionPane;
class SwingAddition{
public static void main(String[]args) throws Exception{
String a = JOptionPane.showInputDialog("Enter Num1");
int x = Integer.parseInt(a);
String s = JOptionPane.showInputDialog("Enter Num2");
int y = Integer.parseInt(s);
int add = x + y;
int mul = x * y;
int div = x / y;
int sub = x - y;
int rem = x % y;
JOptionPane.showMessageDialog(null, "Sum is : " + add);
System.out.print(" \n Sum is: " + add);
JOptionPane.showMessageDialog(null, "Multiplication is : " + mul);
System.out.print(" \n Multiplication is: " + mul);
JOptionPane.showMessageDialog(null, "Division is : " + div);
System.out.print(" \n Division is: " + div);
JOptionPane.showMessageDialog(null, "Subtraction is : " + sub);
System.out.print(" \n Subtraction is: " + sub);
JOptionPane.showMessageDialog(null, "Reminder is : " + rem);
System.out.print(" \n Reminder is: " + rem);
}
}
No comments:
Post a Comment