import java.util.*;
import java.lang.System.*;
import java.awt.*;
import javax.swing.*;
public class calc
{
import java.lang.System.*;
import java.awt.*;
import javax.swing.*;
public class calc
{
private static byte mode;
private static double num1,num2;
public static void main(String[] args)
{
protected static void setMode()
{
protected static byte getMode()
{
}private static double num1,num2;
public static void main(String[] args)
{
Scanner keyboard=new Scanner(System.in);
out.print("Enter the first number. : ");
num1=keyboard.nextDouble();
out.print("Enter the second num. : ");
num2=keyboard.nextDouble();
setMode();
if(getMode()==1)
{
else if(getMode==2)
{
else if(getMode==3)
{
else
{
}out.print("Enter the first number. : ");
num1=keyboard.nextDouble();
out.print("Enter the second num. : ");
num2=keyboard.nextDouble();
setMode();
if(getMode()==1)
{
out.println(num1+num2);
}
else if(getMode==2)
{
out.println(num1-num2);
}
else if(getMode==3)
{
out.println(num1*num2);
}
else
{
out.println(num1/num2);
}
protected static void setMode()
{
Scanner keyboard=new Scanner(System.in);
out.println("Enter 1 for addition. Enter 2 for subtraction. ");
out.print("Enter 3 for multiplication. Enter 4 for division. : ");
try
{
catch(Exception somexception)
{
}out.println("Enter 1 for addition. Enter 2 for subtraction. ");
out.print("Enter 3 for multiplication. Enter 4 for division. : ");
try
{
mode=keyboard.nextByte();
}
catch(Exception somexception)
{
JOptionPane.showMessageDialog(null,"Error. There was a errorso the program must now exit. ");
JOptionPane.showMessageDialog(null,"The program will exit by it self. ");
exit();
}JOptionPane.showMessageDialog(null,"The program will exit by it self. ");
exit();
protected static byte getMode()
{
return mode;
}
Last edited by a moderator: