两只老虎
public class Operatortext {
public static void main(String[] args) {
//定义变量
int weight1=180;
int weight2=200;
boolean b=weight1==weight2?true:false;
System.out.println("b:"+b);
}
}
三个和尚
一座寺庙里住着三个和尚,已知他们的身高分别为150cm.210cm.165cm,请用程序实现获取这三个和尚的最高身高。
public class Operatortext {
public static void main(String[] args) {
//定义变量
int height1=150;
int height2=210;
int height3=165;
//先比较两个和尚的身高
int tempHeight =height1>height2 ? height1:height2;
//再次比较
int maxHeight=tempHeight>height3?tempHeight:height3;
//输出结果
System.out.println("maxHeight:"+maxHeight);
}
}