Using the arithmetic operators to perform algebraic operations on two numbers in JAVA. (Algebraic operation is +, - , *, /, %)
CODING:
import javax.swing.JOptionPane;
class AirOpe
{
public static void main(String[] args)
{
String a=JOptionPane.showInputDialog(null, "A:", "Input Number...",JOptionPane.QUESTION_MESSAGE);
String b=JOptionPane.showInputDialog(null, "B:", "Input Number...", JOptionPane.QUESTION_MESSAGE);
int A=Integer.parseInt(a);
int B=Integer.parseInt(b);
JOptionPane.showMessageDialog(null, A + "+" + B + "=" + (A+B) + "\n" + A + "-" + B + "=" + (A-B) + "\n" + A + "*" + B + "=" + (A*B)
+ "\n" + A + "/" + B + "=" + (A/B) + "\n" + A + "%" + B + "=" + (A%B));
System.exit(0);
}
}
class AirOpe
{
public static void main(String[] args)
{
String a=JOptionPane.showInputDialog(null, "A:", "Input Number...",JOptionPane.QUESTION_MESSAGE);
String b=JOptionPane.showInputDialog(null, "B:", "Input Number...", JOptionPane.QUESTION_MESSAGE);
int A=Integer.parseInt(a);
int B=Integer.parseInt(b);
JOptionPane.showMessageDialog(null, A + "+" + B + "=" + (A+B) + "\n" + A + "-" + B + "=" + (A-B) + "\n" + A + "*" + B + "=" + (A*B)
+ "\n" + A + "/" + B + "=" + (A/B) + "\n" + A + "%" + B + "=" + (A%B));
System.exit(0);
}
}
Comments
Post a Comment