Second max problem

i know it is a trivial question but i am not able to make solution for it . if somebody can help by letting me know where i am lagging then it will be helpful. my code is
public static void main (String[] args) throws java.lang.Exception
Scanner scn = new Scanner(;
int n = scn.nextInt();
int[]arr = new int[n];

	for(int i = 0; i<n; i++){
	       int a = scn.nextInt();
	       int b = scn.nextInt();
	       int c = scn.nextInt();
            System.out.println(b>c ? b: c);
        else if(b>c){
            System.out.println(c>a ? c: a);
        else if(c>a){
            System.out.println(a>b ?  a:b);


if a>b and c>b then you are printing c. Whereas a can also be a possible answer.

Give your submission link

Try with test case
5 4 9
your code will output: 9, but the answer should be 5.

Hope u got the issue!

yeah ok thanks

thanks to you too