A. Introduction
1. We have discussed method calling, parameter passing and return values in Introduction to Java. For a quick review, please see this class below and discuss what the outputs will be.
class _7_1 {
public static int max(int x, int y, int z ){
if(x>=y && x>=z) return x;
else if(y>=z && y>=x) return y;
else return z;
}
public static void max2(int x, int y, int z, int m ){
if(x>=y && x>=z) m=x;
else if(y>=z && y>=x) m=y;
else m=z;
}
public static void main(String[] args) {
int a=710, b=109, c=-870;
int m=0;
System.out.println(max(a, b, c));
max2(a, b, c, m);
System.out.println(m);
}
}
B. Watch .... (Slides)
C. Try this in class:
Write a function to take 3 int parameters and return the smallest of them. Call this function in main( ) to test with both positive and negative input values.