Write a Java public static general function which doesn't belong to the Stack class, isGreaterThan that determines if one stack is greater than another stack. If the summation of every other item(starting at the top) from one stack is greater than the summation of every other item(starting at the top) from another, return true, otherwise, return false. After you call this method, both stacks should stay the same as they are called before. Receives: a Stack type argument S1 and another Stack type argument S2 Postcondition: If the summation of every other item (starting at the top) from S1 is greater than the summation of every other item (starting at the top) from S2, return true, otherwise, return false. Both S1 and S2 should stay the same as they are called before. public static boolean isGreaterThan(Stack S1, Stack S2)
Write a Java public static general function which doesn't belong to the Stack class, isGreaterThan that determines if one stack is greater than another stack. If the summation of every other item(starting at the top) from one stack is greater than the summation of every other item(starting at the top) from another, return true, otherwise, return false. After you call this method, both stacks should stay the same as they are called before.
Receives: a Stack type argument S1 and another Stack type argument S2
Postcondition: If the summation of every other item (starting at the top) from S1 is greater than the summation of every other item (starting at the top) from S2, return true, otherwise, return false. Both S1 and S2 should stay the same as they are called before.
public static boolean isGreaterThan(Stack S1, Stack S2)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images