I am approaching this in a different way than what has been posted by others. I ran multiple scenarios with no issues, IntelliJ passed the assignment but I couldn't get it to show complete, so I tried to submit it through the web, and it will not pass saying that I need to display the middle number. whats wrong????
package com.codegym.task.task04.task0441;
/*
Somehow average
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
int a =Integer.parseInt(rd.readLine());
int b = Integer.parseInt(rd.readLine());
int c = Integer.parseInt(rd.readLine());
System.out.println(MidInt(a, b, c));
}
static int MidInt(int a, int b, int c){
int maxnum= Math.max(Math.max(a, b), Math.max(b, c));
int minnum=Math.min(Math.min(a, b),Math.min(b, c));
int x =(a+b+c);
int midnum = x-maxnum-minnum;
return midnum;
}
}