Package wac.wev.as;
Create a new method to find the maximum value
Import Java.util.Scanner;
public class Maxlian {
public static void Main (string[] args) {
Keyboard Entry and Guide package
Scanner sc= New Scanner (system.in);
Data reception
System.out.println ("Please enter the first data:");
int a = Sc.nextint ();
System.out.println ("Please enter a second data:");
int b = Sc.nextint ();
System.out.println ("Please enter a third data:");
int c = Sc.nextint ();
Method reference
int result = Big (a,b,c);
System.out.println ("The maximum value in three numbers is" +result);
}
Solution method
public static int Big (int a, int b,int c) {
Create a new intermediate value for comparison
int num = (a>b)? A:B;
Then use this value to compare to the last one.
int max = (num>c)? NUM:C;
Maximum output value
return Max;
}
}
Java_ create a new method and ask for the maximum value in three numbers