Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public static void modulus(Stack<String> newStack) {
  2. if(!newStack.isEmpty() && newStack.size() >=2) {
  3. int firstNum = Integer.parseInt((String) newStack.peek());
  4. int secondNum = Integer.parseInt((String) newStack.peek());
  5. if(firstNum <=-1) {
  6. System.err.println("Negative power.");
  7. }
  8. else {
  9. firstNum = Integer.parseInt((String) newStack.pop());
  10. secondNum = Integer.parseInt((String) newStack.pop());
  11. newStack.push(userInput.saturation((long)(int)(secondNum%firstNum)));
  12. }
  13. }
  14. else {
  15. stackUnderflow();
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement