Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!

pshivvy pat

Greenhorn
+ Follow
since Feb 10, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by pshivvy pat

Mohammed Al-otaibi wrote:. . . it is working fine but with delibrate number entry
it gives erroneous results with other mixed values



Could you tell me a set your tried?
1 week ago

Paul Clapham wrote:Okay. So I could enter -2 and -4 and -17 and your code would go on to find the second largest of those three numbers? What would it output?



It returns 0 if only negative values are entered, unless it is -1. Then, it stops.
1 week ago

Campbell Ritchie wrote:

pshivvy pat wrote:. . . -1 is there as a value which we were instructed to stop at. . . .

That sort of code suggests you are only dealing with natural numbers. . . .



I think there is a misunderstanding. The program has to stop if a user -1, that was what our rules stated.
1 week ago

Paul Clapham wrote:

Campbell Ritchie wrote:The problem about −1 comes from misunderstanding the loop in line 7. All you have to do is enter a non‑integer and the loop terminates. No need for −1 or break; or anything like that.



Right. But what if I wanted to use -1 as one of the numbers I'm inputting? Or some other negative numbers? The posted code won't handle those properly.



I apologize for the late reply. -1 is there as a value which we were instructed to stop at. If userInput is -1, the loop stops. Otherwise, it runs.
1 week ago


I made a code which takes all user inputs and then adds it into an array list. I am fine with what I have there. I am confused as to why the for loop returns the largest number even though my logic tells me it should return the second smallest one. Any help is appreciated!
1 week ago