Help me in solving SNDMAX problem

My issue

approach

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
        
	}
}

Problem Link: Second Max of Three Numbers Practice Coding Problem - CodeChef

@niveshl
plzz refer my c++ code for better understanding of the logic

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int a,b,c;
	    cin>>a>>b>>c;
	    if((a>b&&a<c)||(a>c&&a<b))
	    cout<<a;
	    else if((b>c&&b<a)||(b>a&&b<c))
	    cout<<b;
	    else
	    cout<<c;
	    cout<<endl;
	}
	return 0;
}