158k views
1 vote
The Math class provides a static method, max, that accepts two int arguments and returns the value of the larger one. Four int variables, population1, population2, population3, and population4 have already been declared and initialized. Write an expression (not a statement!) whose value is the largest of population1, population2, population3, and population4 by calling max.

User Muratiakos
by
7.3k points

1 Answer

1 vote

Answer:

max (max (max (population1, population2) , population3), population4)

Explanation:

max accepts two int arguments and returns the value of the larger one:

max (i,j) = i if i>j or =j if j<i

Four int variables, population1, population2, population3, and population4

max (population1, population2) ⇒ return the larger one between population1 and population2

max (max (population1, population2) , population3) ⇒ return the larger one between the largest one between population1 and population2 and population3

max (max (max (population1, population2) , population3), population4) ⇒ return the larger one between population1, population2, population3 and population4

An expression whose value is the largest of population1, population2, population3, and population4 by calling max is:

max (max (max (population1, population2) , population3), population4)

User Don F
by
7.5k points