-3

An input of string is passed as an argument to a comptute function.The string can contain up to three values of numbers and some operators like * - / +? For example, "25.7-14*34" is valid

This is the format:

public double compute(String input){
    ...
}

I think I would need a condition to check if a character is an operator but I don't know how to check for it in Java. Can someone please help me out?

Manuel
  • 976
  • 3
  • 9
  • 21

1 Answers1

0

You can use Character class in case you are planning to do it yourself.

Character.isLetterOrDigit(), Character.getType(c) == Character.MATH_SYMBOL to check whether the character passed c is a math symbol or not. There are a lot of other static methods present in Character class which you can make use of.

Tirath
  • 2,294
  • 18
  • 27