Classic Bug (2)

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

The maximum is   -12.

Classic Bug (2)

Classic Bug (2): It is tempting to say that the maximum is -92, since -92 seems to be a bigger number than -12. But this is confusing the absolute value of a number with its position on the number line. If you are looking for the maximum of a list of numbers, you are looking for the number which is furthest to the right on the number line.

number line full of negatives

Or, think of this as pay. If Jill is paid -92 dollars a day and Joe is paid -12 dollars a day, who is paid the most? (And exactly which fast food restaurant do they work at?)

QUESTION 11:

What is the minimum of this list of integers:

-45,  -23,  -87,  -56,  -92,  -12,  -36