Delete comment from: Java67
import java.io.*;
import java.util.*;
class calci{
int a,b,c,d,e,f,g;{
Scanner cal= new Scanner(System.in);
System.out.println("Enter the first number :");
a = cal.nextInt();
System.out.println("Enter the second number :");
b = cal.nextInt();
public static int add()
{
c=a+b;
System.out.println("Addition of 2 numbers is"+c);
return c;
}
public static void sub()
{
d=a-b;
System.out.println("Subtraction of 2 numbers is ="+d);
return d;
}
public static int mul()
{
e=a*b;
System.out.println("Multiplication of 2 numbers is ="+e);
return e;
}
public static int div()
{
f=a/b;
System.out.println("Division of 2 numbers is ="+f);
return f;
}
public static int mod()
{
g=a%b;
System.out.println("Modulo of 2 numbers is ="+g);
return g;
}
}
}
class calculator_2{
public static void main(String [] args){
int ch;
System.out.println("1.ADDITION \n2.SUBTRACTION \n3.MULTIPLICATION \n4.DIVISION \n5.MODULO");
calci obj=new calci();
Scanner in =new Scanner(System.in);
System.out.println("Enter Your Choice :\t");
ch = in.nextInt();
switch(ch)
{
case 1: obj.add();
break;
case 2: bj.sub();
break;
case 3: obj. mul();
break;
case 4: obj.div();
break;
case 5: obj.mod();
break;
default :System.out.println("option not avilable");
break;
}
}
}
Aug 18, 2019, 1:38:58 PM
Posted to How to fix "illegal start of expression" error in Java? Example