CODING:
import javax.swing.JOptionPane;
class Cal
{
public static void main(String[] args)
{
String a=JOptionPane.showInputDialog(null, "Enter Number Of A..", "Calculator", JOptionPane.PLAIN_MESSAGE);
String b=JOptionPane.showInputDialog(null, "Enter Number Of B..", "Calculator", JOptionPane.PLAIN_MESSAGE);
String c=JOptionPane.showInputDialog(null, "Which Operation..\n+\n-\n*\n/\n%", "Calculator", JOptionPane.PLAIN_MESSAGE);
switch(c)
{
case "+":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "+" + Integer.parseInt(b) + "=" + (Integer.parseInt(a)+Integer.parseInt(b)));
break;
case "-":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "-" + Integer.parseInt(b) + "=" + (Integer.parseInt(a)-Integer.parseInt(b)));
break;
case "*":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "*" + Integer.parseInt(b) + "=" + Integer.parseInt(a)*Integer.parseInt(b));
break;
case "/":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "/" + Integer.parseInt(b) + "=" + Integer.parseInt(a)/Integer.parseInt(b));
break;
case "%":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "%" + Integer.parseInt(b) + "=" + Integer.parseInt(a)%Integer.parseInt(b));
break;
default:
JOptionPane.showMessageDialog(null,"Invalid Enter Operation...");
}
System.exit(0);
}
}
class Cal
{
public static void main(String[] args)
{
String a=JOptionPane.showInputDialog(null, "Enter Number Of A..", "Calculator", JOptionPane.PLAIN_MESSAGE);
String b=JOptionPane.showInputDialog(null, "Enter Number Of B..", "Calculator", JOptionPane.PLAIN_MESSAGE);
String c=JOptionPane.showInputDialog(null, "Which Operation..\n+\n-\n*\n/\n%", "Calculator", JOptionPane.PLAIN_MESSAGE);
switch(c)
{
case "+":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "+" + Integer.parseInt(b) + "=" + (Integer.parseInt(a)+Integer.parseInt(b)));
break;
case "-":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "-" + Integer.parseInt(b) + "=" + (Integer.parseInt(a)-Integer.parseInt(b)));
break;
case "*":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "*" + Integer.parseInt(b) + "=" + Integer.parseInt(a)*Integer.parseInt(b));
break;
case "/":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "/" + Integer.parseInt(b) + "=" + Integer.parseInt(a)/Integer.parseInt(b));
break;
case "%":
JOptionPane.showMessageDialog(null,Integer.parseInt(a) + "%" + Integer.parseInt(b) + "=" + Integer.parseInt(a)%Integer.parseInt(b));
break;
default:
JOptionPane.showMessageDialog(null,"Invalid Enter Operation...");
}
System.exit(0);
}
}
Comments
Post a Comment