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

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/12013070.html