61本章作业2
1:使用char类型,分别保存\n \t \r \ 1 2 3 等字符并打印输出
Homework02.java
2: 编程,保存两本书名,用+号拼接 看效果. 保存两本书价格,用+号拼接
3:编程实现如下效果Homework04.java
姓名 年龄 成绩 性别 爱好
xx xx xx xx xx
要求
1:用变量将姓名,年龄,成绩,性别,爱好存储
2:使用+拼接
3:写注释
4:添加转义字符,使一条语句输出
public class Homework02 {
//编写一个main方法
public static void main (String[]args){
//使用char类型,分别保存\n \t \r \\ 1 2 3 等字符并打印输出
char c1 ='\n';
char c2 = '\t';
char c3 = '\r';//回车
char c4 = '\\';//输出\
char c5 = '1';//1
char c6 = '2';//2
char c7 = '3';//3
System.out.println(c1);
//System.out.println("----------------");
public class Homework03 {
//编写一个main方法
public static void main (String[]args){
//编程,保存两本书名,用+号拼接 看效果. 保存两本书价格,用+号拼接
String book1 ="百万英镑"
String book1 ="丰碑"
System.out.println("book1" + book2);//百万英镑丰碑
//性别应该使用char保存
char sex1 ='男';
char sex2 ='女';
System.out.println("sex1"+sex2);//男女
//保存两本书的价格
double bookone= 99.11;
int booktwo= 666.45;
System.out.prinln(bookone + booktwo);
//要求
//1:用变量将姓名,年龄,成绩,性别,爱好存储
//2:使用+拼接
//3:写注释
//4:添加转义字符,使一条语句输出
public class Homework04 {
//编写一个main方法
public static void main (String[]args){
String name = "peter";
int age = 18;
int score = 100;