hc学习平台

 找回密码
 立即注册
搜索
热搜: 活动 交友 javakc
 › 石茹 › 日志

写出if语句的句法结构,写一个关于if的练习  

2022-08-05 16:51:15 查看(50) 回复(0)

public class text_if {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入第一个数字");
        int x = scan.nextInt();
        System.out.println("请输入第二个数字");
        int y = scan.nextInt();

        if (x > y) {
            System.out.println(x + "大于" + y);
        } else if (x < y) {
            System.out.println(x + "小于" + y);
        } else {
            System.out.println(x + "等于" + y);

        }
    }
}

评论 (0 个评论)

facelist

全部作者的其他最新日志



站点统计|举报|Archiver|手机版|小黑屋|Comsenz Inc.

GMT+8, , Processed in 0.195171 second(s), 9 queries .

Powered by javakc! X1.0

© 2004-2014 javakc

f1208.com 备案号:京ICP备14030918号-1

返回顶部