From c0f47a9ed430668c642ac1211ca25ee0678281b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=95=85=E6=98=A5?= <3481369387@qq.com> Date: Thu, 19 Mar 2026 10:26:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=89=80=E6=9C=89=E6=89=80?= =?UTF-8?q?=E6=9C=89=E4=BD=9C=E4=B8=9A=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 49 +++++++------------------------------------------ README2.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 README2.md diff --git a/README.md b/README.md index c5e07a9..192606f 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,9 @@ -// Student.java -public class Student { -// 成员属性 -private int studentId; -private String name; -private double score; +# 温度转换程序(Java版) +## 功能 +实现摄氏温度与华氏温度的相互转换,输入格式:温度值 + 空格 + 单位(C/F),例如 `36.6 C`。 - // 构造方法(用于创建对象时给属性赋值) - public Student(int studentId, String name, double score) { - this.studentId = studentId; - this.name = name; - this.score = score; - } +## 编译与运行命令 +1. 编译:`javac TemperatureConverter.java` +2. 运行:`java TemperatureConverter` - // study() 方法 - public void study() { - System.out.println(name + "(学号:" + studentId + ")正在学习,当前成绩:" + score); - } - - // 可选:getter/setter 方法(用于访问/修改私有属性) - public int getStudentId() { - return studentId; - } - - public String getName() { - return name; - } - - public double getScore() { - return score; - } -} - -public class Main { -public static void main(String[] args) { -// 实例化两个 Student 对象 -Student stu1 = new Student(2026001, "张三", 90.5); -Student stu2 = new Student(2026002, "李四", 88.0); - - // 调用 study() 方法 - stu1.study(); - stu2.study(); - } -} \ No newline at end of file +## 示例输出 \ No newline at end of file diff --git a/README2.md b/README2.md new file mode 100644 index 0000000..5a9bda6 --- /dev/null +++ b/README2.md @@ -0,0 +1,44 @@ +// Student.java +public class Student { +// 成员属性 +private int studentId; +private String name; +private double score; + + // 构造方法(用于创建对象时给属性赋值) + public Student(int studentId, String name, double score) { + this.studentId = studentId; + this.name = name; + this.score = score; + } + + // study() 方法 + public void study() { + System.out.println(name + "(学号:" + studentId + ")正在学习,当前成绩:" + score); + } + + // 可选:getter/setter 方法(用于访问/修改私有属性) + public int getStudentId() { + return studentId; + } + + public String getName() { + return name; + } + + public double getScore() { + return score; + } +} + +public class Main { +public static void main(String[] args) { +// 实例化两个 Student 对象 +Student stu1 = new Student(2026001, "张三", 90.5); +Student stu2 = new Student(2026002, "李四", 88.0); + + // 调用 study() 方法 + stu1.study(); + stu2.study(); + } +} \ No newline at end of file