Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void modulus(Stack<String> newStack) {
- if(!newStack.isEmpty() && newStack.size() >=2) {
- int firstNum = Integer.parseInt((String) newStack.peek());
- int secondNum = Integer.parseInt((String) newStack.peek());
- if(firstNum <=-1) {
- System.err.println("Negative power.");
- }
- else {
- firstNum = Integer.parseInt((String) newStack.pop());
- secondNum = Integer.parseInt((String) newStack.pop());
- newStack.push(userInput.saturation((long)(int)(secondNum%firstNum)));
- }
- }
- else {
- stackUnderflow();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement