Java If循环语句,学习代码。个人源代码。

 public class xb {
            public static void main(String[] args) {
                java.util.Scanner s = new java.util.Scanner(System.in);

                System.out.println("欢迎使用次系统");
                System.out.println("说明:1.表示下雨,0表示晴天");
                System.out.println("说明1:1表示男,0表示女");
                //接受性别
                System.out.print("请输入性别:");
                int sex = s.nextInt();
                //接受天气状况
                System.out.print("请输入当前天气状况:");
                int weather = s.nextInt();

                //判断天气状况
                if (weather == 1) {
                    //下雨天
                    //System.out.println("下雨天");
                    if (sex == 1) {
                        System.out.println("带一把大黑伞");
                    } else if (sex == 0) {
                        System.out.println("带一把小花伞");
                    } else {
                        System.out.println("对不起,您的性别是怎么回事");
                    }
                } else if (weather == 0) {
                  //接受温度
                    System.out.print("请输入温度:");
                    int tem = s.nextInt();
                    if (tem >= 30) {
                        if (sex == 1) {
                            System.out.println("戴墨镜");
                        } else if (sex == 0) {
                            System.out.println("擦防晒霜");
                        } else {
                            System.out.println("对不起,您的性别是怎么回事");
                        }
                  }else if(tem>16){
                        System.out.println("天气还是比较凉爽");
                    }else {
                        System.out.println("天气太冷了要穿棉衣");
                    }
              }else{
                System.out.println("对不起,您输入的天气不存在");
          }
    }
}
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

never stop learning

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值