Answers for "convert character to operator java"

0

how to convert character into operator

int Compute(char c, int a, int b)
{
    switch (c) {  
    case '+': return a+b;
    case '-': return a-b;
    case '*': return a*b;
    case '/': return a/b;
    default: throw std::runtime_error("No such operator");
    }
}
Posted by: Guest on May-25-2021

Code answers related to "convert character to operator java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language