greatest among three numbers

妖精的绣舞 提交于 2019-12-09 20:01:25

 

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

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!