Skip to main content

Find Second highest Number in JAVA.(Number is declare before in program.)

Declare three variable with value and after find Second highest Number.
CODING:
class high{
 public static void main(String args[])
  {
    int a=45,b=60,c=53,s;//in s variable stored second highest number.
     if(a<b){
      if(b<c){s=b;}
      else if(c>a){s=c;}
      else{s=a;}   
     }
    else if(a>c){
      if(c>b){s=c;}
      else{s=b;}
    }
    else{s=a;}
   System.out.println("Second Hightest Number :" + s);
  }
}

Comments