2017/6/22作业小结

来源:互联网 发布:华为ac6605端口镜像 编辑:程序博客网 时间:2024/06/07 18:12

//求是否为正数

public class Java_22 {
public static void main(String[] args) {
int a=0;
if(a>=0){
System.out.println("它为正数");
}else if(a<0){
System.out.println("它为负数");
}else{
System.out.println("他不为正数");
}

}
}

//高:180cm以上 ,富:1千万以上, 帅:是

public class Java_23 {


public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入您的身高(cm):");
int cm = input.nextInt();
System.out.println("请输入您的身价(千万):");
int qw = input.nextInt();
System.out.println("请输入您是否帅(true/false):");
boolean shuai = input.nextBoolean();
if (cm > 180 && qw > 1000 && shuai == true) {
System.out.println("我一定要嫁给他!!!");
} else if (cm > 180 || qw > 1000 || shuai == true) {
System.out.println("嫁吧,比上不足,比下有余.");
} else if (cm <= 180 && qw <= 1000 && shuai == false) {
System.out.println("不嫁");
}
}
}

原创粉丝点击