Calculator by java programming language
import java.util.Scanner;
public class Calculator{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
char opr;
float a,b;
System.out.println("input the value\t");
a = input.nextFloat();
opr = input.next().charAt(0);
b = input.nextFloat();
if(opr=='+')
{
System.out.print(a+b);
}
else if(opr=='-')
{
System.out.print(a-b);
}
else if(opr=='*')
{
System.out.print(a*b);
}
else if(opr=='/')
{
System.out.print(a/b);
}
else{
System.out.println("error occurred");
}
}
}
Comments
Post a Comment