/* Write a Java program that reads 3 integers in the main() method. Pass the 3 integers to a method called "max" that calculates the largest of the 3 numbers and returns it. Print the largest number in main */ import java.util.Scanner; class Quiz10_14 { /* This method called "max", accepts 3 integer parameters and returns an integer*/ static int max(int x, int y, int z) { if( x>y && x>z) // x is the largest return x; else if( y > x && y > z) // y is the largest return y; return z; // will get here only if z is the largest. Would have returned x or y otherwise. } // The main() method public static void main(String [] args) { Scanner in = new Scanner(System.in); int a,b,c; System.out.println("Enter 3 numbers: "); // read in the 3 integers. a = in.nextInt(); b = in.nextInt(); c = in.nextInt(); //function call. The returned value is stored in the integer "largest" int largest = max(a,b,c); System.out.println("The largest number is " + largest); } }