| ||A simple calculator accepts the following kinds of strings as input:
where NUM is a positive integer, between 1 and 10000 inclusive that can contain leading zeros. Return the value produced by the given expression. Here +,-,*, and / denote addition, subtraction, multiplication and division respectively. All operations are done on integers, so "5/3" returns 1.
- 1) NUM+NUM
- 2) NUM-NUM
- 3) NUM*NUM
- 4) NUM/NUM
|Method signature:||int calculate(String input)|
|(be sure your method is public)|
|-||input will contain between 3 and 50 characters inclusive.|
|-||input will have the form <NUM><OP><NUM> where|
<NUM> is a positive integer between 1 and 10000 inclusive, that may contain leading zeros and
<OP> is one of (quotes for clarity) '+','*','-', or '/'.
|-||input will not contain any spaces.|
|Remember integer division is used, so results are truncated.|
|Negative results are allowed.|
|The long way of writing 18/9.|
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.