greatest among three numbers

 

public class Solution {
    public static void main(String[] args) {
        Scanner ip = new Scanner(System.in);
        System.out.print("Enter A: ");
        int a = ip.nextInt();
        System.out.print("Enter B: ");
        int b = ip.nextInt();
        System.out.print("Enter C: ");
        int c = ip.nextInt();
        int great = a >= b ? (a >= c ? a : c) : (b >= c ? b : c);
        System.out.println("Greatest among three numbers is: " + great);
        ip.close();
    }
}



OUTPUT:
Enter A: 1
Enter B: 2
Enter C: 3
Greatest among three numbers is: 3

 

posted @ 2019-12-09 19:47  anobscureretreat  阅读(91)  评论(0编辑  收藏  举报