侧边栏壁纸
  • 累计撰写 53 篇文章
  • 累计收到 5 条评论

Chapter 03

bbchen
2022-09-15 / 0 评论 / 143 阅读 / 正在检测是否收录...

数据类型

image-20220826114954704

答:输出为:

n3 = 30
n5 = 8

public class Homework02 {

    public static void main(String[] args) {

        char c1 = '\n'; // 换行
        char c2 = '\t'; // 制表位
        char c3 = '\r'; // 回车
        char c4 = '\\'; // 输出/
        char c5 = '1'; 
        char c6 = '2';
        char c7 = '3';
        System.out.println(c1);
        System.out.println(c2);
        System.out.println(c3);
        System.out.println(c4);
        System.out.println(c5);
        System.out.println(c6);
        System.out.println(c7);
    }

}

运行结果:

image-20220826133706343

image-20220826133757881

public class Homework03 {

    public static void main(String[] args) {
        
        String book1 = "三体";
        String book2 = "习近平谈治国理政";
        System.out.println(book1 + book2);  // 三体习近平谈治国理政

        char c1 = '男';
        char c2 = '女';
        System.out.println(c1 + c2);    // 得到码值

        double price1 = 12.34;
        double price2 = 11.01;
        System.out.println(price1 + price2);    // 即为小数相加
    }

}

运行结果:

image-20220826134406991

image-20220826134522884

public class Homework04 {

    public static void main(String[] args) {
        
        String name = "Jack";
        int age = 20;
        double score = 90.5;
        char gender = '男';
        String hobby = "打篮球";
        System.out.println("姓名\t年龄\t成绩\t性别\t爱好\n" + name + "\t" +
                            age + "\t" + score + "\t" + gender +
                             "\t" + hobby
        );
    }
}

运行结果

image-20220826135109554

0

评论

博主关闭了所有页面的评论