am trying to make a simple calculator but i really want something more than this ,here is my code :
package revolution;
import java.util.Scanner;
public class simplecalculator {
public static void main(String[] args){
int x , y ,result = 0 ;
char c;
Scanner input = new Scanner(System.in);
//gather user inputs
System.out.print("ENTER NO.: ");
x = input.nextInt();
System.out.print("enter operator: ");
String st = input.next();
c = st.charAt(0);
System.out.print("ENTER NO.: ");
y = input.nextInt();
switch(c){
case'+':
result = x + y;
System.out.print("SUM: "+result);
break;
case'-':
result = x - y ;
System.out.print("DIFFERENCE: "+result);
break;
case '*':
result = x*y;
System.out.print("MULTIPLE: "+result);
break;
case '/':
result = x/y;
if(y == 0){
System.out.print("ERRORIVISION BY ZERO");
}else{
System.out.print("DIVISION: "+result);
}
break;
default:
System.out.print("SYNTAX ERROR");
}
}
}
any one with much more better idea than this ..........would be happy to share