Write a method called evalExpr (which stands for ``evaluate expression'') that take a String as an argument and that returns an integer. The String will be an arithmetic expression including exactly three numbers and two of the operators + and -.
For example: "1 + 2 + 3" and "99 + 98 - 317" and "13685483 - 27385 + 87654".
Your method should evaluate the expression, returning the result. For the examples above, the return values would be 6, -120 and 13745752. Here are some additional rules:
int Integer.valueOf (String s);
You may assume that valueOf works correctly even if there are spaces before or after the number, but not if there are any other non-digit characters in the String. In other words, Integer.valueOf (" 123 ") is ok, but Integer.valueOf ("a123") is not. Your program does not have to check for illegal numbers; you may assume that the String you are given is properly-formed.
String name = "Allen Downey";
System.out.println (name.substring(2,4));
Unfortunately, I think you will find that the implemenation of substring in our IDE is not correct. You will have to adjust your program accordingly.
YOU DO NOT NEED TO WRITE EITHER valueOf OR substring.
HINT: You should not give any consideration to making your solution efficient. It is much more important, for the time being, to write something correct rather than fast.
As in the previous question, you will want to write a simple main method that tests your program.