Skip to content

Instantly share code, notes, and snippets.

@staffordsmith83
Last active August 19, 2020 12:03
Show Gist options
  • Save staffordsmith83/038a6f9964516312368df65b414b51f8 to your computer and use it in GitHub Desktop.
Save staffordsmith83/038a6f9964516312368df65b414b51f8 to your computer and use it in GitHub Desktop.
A method that takes three integer numbers and returns the position of the first maximum in the order of the method parameters.
import java.util.Scanner;
public class Main {
public static int getNumberOfMaxParam(int a, int b, int c) {
int result = 1;
if (b > a) {
result = 2;
if (c > b) {
result = 3;
}
} else if (c > a) {
result = 3;
}
return result;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
final int a = scanner.nextInt();
final int b = scanner.nextInt();
final int c = scanner.nextInt();
System.out.println(getNumberOfMaxParam(a, b, c));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment