0
I have a problem en Java
I have a problem, let's say I have a stack of numbers and the user is asked for a number to compare with all the elements of the stack and to know if it is greater or less.
4 Answers
+ 2
Please show us your code as this will allow the community to address your problem correctly.
Please use the 8 rules for getting help from the community.
https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community
Thanks and happy coding
+ 2
you should specify your problem more. đ
lets say the input is called x.
one might understand x needs to be greater than every element of the stack.
one might understand x needs to be greater than the average of all elements in the stack.
one might understand x needs to be greater than the sum of all elements of the stack.
one might understand x needs to be greater than half of the elements of the stack.
one might understand x needs to be greater than the smallest number in the stack.
you see, the problem is not really clear đ
besides what do you have trouble with?
-theorie behind algorithm
-implementation of algorithm
-implementation of Stack
...
+ 1
I am having trouble implementing the algorithm.
What I will explain, for example, create a stack and add 8 and 9, and then after the user is asked to enter an x âânumber, they will have to compare it to ALL THE ELEMENTS THAT MAKE UP THE BATTERY. So it is already clearer.
AND IF THE X IS LESS THAN THE NUMBER OF THE STACK. IT WILL LAUNCH A MESSAGE IN CONSOLE THAT WILL SAY LESS IF IT WOULD NOT BE GREATER.
+ 1
does this help you? đ
https://code.sololearn.com/chUjJPd0hat7/?ref=app