Computer Science, asked by angelrajput, 1 year ago

can somebody help me in java coding of a numerical calculator

Answers

Answered by JamesBondOO7
2
import java.util.Scanner;
class assa
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter first value");
int a=sc.nextInt();
System.out.println("Enter second value");
int b=sc.nextInt();
System.out.println("Enter operator");
char c=sc.next().charAt(0);
int s;
if(c=='+')
{
s=a+b;
}
else if(c=='-')
{
s=a-b;
}
else if(c=='*')
{
s=a*b;
}
else if(c=='/')
{
s=a/b;
}
else
{
System.out.println("Invalid input");
}
System.out.println("Ans = "+s);
}
}

angelrajput: tysmmmm
Similar questions