Median of three numbers

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int median; if (a > b) { if (a < c) median=a; else if (b > c) median=b; else median=c; } else { if (a > c) median=a; else if (b < c) median=b; else median=c; } System.out.println(median); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.