February 2014
Beginner
1248 pages
62h 25m
English
Methods often require more than one piece of information to perform their tasks. We now consider how to write your own methods with multiple parameters.
Figure 6.3 uses a method called maximum to determine and return the largest of three double values. In main, lines 14–18 prompt the user to enter three double values, then read them from the user. Line 21 calls method maximum (declared in lines 28–41) to determine the largest of the three values it receives as arguments. When method maximum returns the result to line 21, the program assigns maximum’s return value to local variable result. Then line 24 outputs the maximum value. At the end of this section, we’ll discuss the use of operator + in line ...
Read now
Unlock full access