JAVA编写一个学生类的程序
答案:2 悬赏:50 手机版
解决时间 2021-01-13 05:49
- 提问者网友:眉目添风霜
- 2021-01-13 02:37
JAVA编写一个学生类的程序
最佳答案
- 五星知识达人网友:三千妖杀
- 2021-01-13 03:18
学生类:
public class Student{
private String name;
private int age;
private double score;
public dd(String name, int age, double score) {
super();
this.name = name;
this.age = age;
this.score = score;
}
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;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
public void printInfo()
{
System.out.println("name:"+name);
System.out.println("age:"+age);
System.out.println("score:"+score);
}
} main() 方法:public class TestStudent{
public static void main(String[] args) {
Student stu=new Student("李四",20,89);
stu.printInfo();
}} 友情提示:考试的题目还是应该自己做,尽管就是做错了,那对自己还是很有帮助的
public class Student{
private String name;
private int age;
private double score;
public dd(String name, int age, double score) {
super();
this.name = name;
this.age = age;
this.score = score;
}
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;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
public void printInfo()
{
System.out.println("name:"+name);
System.out.println("age:"+age);
System.out.println("score:"+score);
}
} main() 方法:public class TestStudent{
public static void main(String[] args) {
Student stu=new Student("李四",20,89);
stu.printInfo();
}} 友情提示:考试的题目还是应该自己做,尽管就是做错了,那对自己还是很有帮助的
全部回答
- 1楼网友:人间朝暮
- 2021-01-13 03:24
先写实体类(学生类):class Student(){ public String name; public int age; public double score; public Student(String name,int age,double score){ this.name=name; this.age=age; this.score=score; } public void printInfo(){ System.out.println("name:"+name+“;age”+age+“;score”+score); } }然后写主程序:class Test(){ public static void main(String [] arges){ Student stu=new Student("黎明",24,100); stu.printInfo(); }}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯