学号在java中的代码 java里输出学号的程序是什么
编写一个java程序,要求输入自己的学号姓名
import java.io.BufferedReader;
创新互联公司长期为数千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为浙江企业提供专业的网站设计、成都网站制作,浙江网站改版等技术服务。拥有十载丰富建站经验和众多成功案例,为您定制开发。
import java.io.IOException;
import java.io.InputStreamReader;
public class Test222 {
public static void main(String[] args) throws IOException {
int i, j;
String a;
BufferedReader str = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("请输入学号:");
a = str.readLine();
System.out.println("学号为:" + a);
str = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入姓名:");
a = str.readLine();
System.out.println("姓名为:" + a);
}
}
望采纳~~
求java中类似学生信息管理系统中按学号,按姓名排序的代码
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class Sort {
public static void main(String[] args) {
Student p1 = new Student(1001, "小明", 20);
Student p2 = new Student(1002, "小红", 21);
Student p3 = new Student(1003, "小黑", 19);
ListStudent list = new ArrayListStudent();
list.add(p1);
list.add(p2);
list.add(p3);
Collections.sort(list, new ComparatorStudent() {
/*
* int compare(Student o1, Student o2) 返回一个基本类型的整型, 返回负数表示:o1 小于o2,
* 返回0 表示:o1和o2相等, 返回正数表示:o1大于o2。
*/
public int compare(Student o1, Student o2) {
// 按照学生的学号进行升序排列
if (o1.getId() o2.getId()) {
return 1;
}
if (o1.getId() == o2.getId()) {
return 0;
}
return -1;
}
});
write(list);
System.out.println("---------------------");
Collections.sort(list, new ComparatorStudent() {
/*
* int compare(Student o1, Student o2) 返回一个基本类型的整型, 返回负数表示:o1 小于o2,
* 返回0 表示:o1和o2相等, 返回正数表示:o1大于o2。
*/
public int compare(Student o1, Student o2) {
// 按照学生的年龄进行升序排列
if (o1.getAge() o2.getAge()) {
return 1;
}
if (o1.getAge() == o2.getAge()) {
return 0;
}
return -1;
}
});
write(list);
}
public static void write(ListStudent list) {
for (Student s : list) {
System.out.println(s.getId() + "\t" + s.getName() + "\t"
+ s.getAge());
}
}
}
public class Student {
private int id ;
private String name;
private int age;
//构造方法
public Student(int id,String name,int age){
this.id = id;
this.name = name;
this.age = age;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
java程序设计,求代码 1.定义学生类,学生类有学号,姓名,语文成绩,数学成绩的属性和有参的构造
import java.util.Comparator;
public class Student implements ComparableStudent {
private int no;
private String name;
private String sex;
private int roomNo;
private double score;
public Student(int no, String name, String sex, int roomNo, double score) {
this.no = no;
this.name = name;
this.sex = sex;
this.roomNo = roomNo;
this.score = score;
}
public Student(int no, String name, String sex, double score) {
this.no = no;
this.name = name;
this.sex = sex;
this.score = score;
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public int getRoomNo() {
return roomNo;
}
public void setRoomNo(int roomNo) {
this.roomNo = roomNo;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
@Override
public int compareTo(Student o) {
if (this.no o.no) return 1;
else if (this.no o.no) return -1;
else return 0;
}
@Override
public String toString() {
return "Student{" +
"no=" + no +
", name='" + name + '\'' +
", sex='" + sex + '\'' +
", roomNo=" + roomNo +
", score=" + score +
'}';
}
}
//性别比较器类
class SexComparator implements ComparatorStudent {
@Override
public int compare(Student o1, Student o2) {
if (o1.getSex().compareTo(o2.getSex()) 0) return 1;
else if (o1.getSex().compareTo(o2.getSex()) 0) return -1;
else return 0;
}
}
//寝室号比较器类
class RoomNoComparator implements ComparatorStudent {
@Override
public int compare(Student o1, Student o2) {
if (o1.getRoomNo() o2.getRoomNo()) return 1;
else if (o1.getRoomNo() o2.getRoomNo()) return -1;
else return 0;
}
}
//入学成绩比较器类
class ScoreComparator implements ComparatorStudent {
@Override
public int compare(Student o1, Student o2) {
if (o1.getScore() o2.getScore()) return 1;
else if (o1.getScore() o2.getScore()) return -1;
else return 0;
}
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class TestStudent {
public static void main(String[] args) {
Student s1 = new Student(1, "jack", "boy", 90);
Student s2 = new Student(5, "jack", "boy", 90);
Student s3 = new Student(4, "jack", "boy", 90);
Student s4 = new Student(2, "jack", "boy", 90);
ListStudent studentList=new ArrayList();
studentList.add(s1);
studentList.add(s2);
studentList.add(s3);
studentList.add(s4);
Collections.sort(studentList);
System.out.println(Arrays.toString(studentList.toArray()));
}
}
在java中,学生的学号可以用mt表示吗
不可以。java是一种面向对象的编程语言。在java语言中,学生的学号只能用sno表示,不能使用其他字母组合进行表示,所以不能用mt表示,java语言具有功能强大和简单易用两个特征,具有简单性、面向对象、分布式等特点,可以编写桌面应用程序、Web应用程序、分布式系统和嵌入式系统应用程序等。
怎么编写一个简单Java应用程序,输出自己的姓名和学号?
下面是一个java 小程序实现的\x0d\x0aimport java.awt.*;//引入包\x0d\x0aimport java.applet.Applet;//引入包\x0d\x0apublic class Output extends Applet//定义类\x0d\x0a{\x0d\x0a //定义变量\x0d\x0a private String name;\x0d\x0a private int num;\x0d\x0a //初始化\x0d\x0a public void init()\x0d\x0a {\x0d\x0a name = getParameter("vname");\x0d\x0a num = Integer.parseInt(getParameter("vnum"));\x0d\x0a }\x0d\x0a //输出\x0d\x0a public void paint(Graphics g)\x0d\x0a {\x0d\x0a g.drawString ("姓名:"+name+";学号:"+num,20,30);\x0d\x0a }\x0d\x0a}\x0d\x0a\x0d\x0a相应的html文件\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a
文章标题:学号在java中的代码 java里输出学号的程序是什么
当前URL:http://pwwzsj.com/article/hjohpo.html