Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In this project, you are going to be creating a simple calculator that will only operate on positive numbers. Your program has already been set up to take in a single line of input formatted as a String, without spaces. You may assume that the input is guaranteed to be valid. The output should be something like "The result is ____".
- Your result must be printed as an integer.
- Your program should be able to handle the following operators:
- Addition
- Subtraction
- Multiplication
- Division
- Modulo
- You may find a new String method, .contains(), to be helpful.
- .contains(char/String)
- returns: true if the char/String is found in the original String, false otherwise
- You can use the following to convert Strings to ints (assuming they can be converted):
- Integer.parseInt(str);
- Sample input/output:
- In:53-22
- The result is 31
- In:39%4
- The result is 3
- In: 65
- The result is 32
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement