定义学生类Student, 其中属性有 name, id, score ,分别表示姓名,学好,成绩;
构造方法 : Student(String n, String i, int s);
成员方法: int getScore();
main函数中创建5个Student的对象,输入姓名学号成绩,并输出他们的平均成绩,最高分和最低分。
本人是初学者,望大神给出代码,最好有注释,谢了。
å®ä¹ä¸ä¸ªè¡¨ç¤ºå¦çä¿¡æ¯çç±»Studentï¼è¦æ±å¦ä¸ï¼
ï¼1ï¼ç±»Studentçæååéï¼
sNOã表示å¦å·ï¼sName表示å§åï¼sSex表示æ§å«ï¼sAge表示年é¾ï¼sJavaï¼è¡¨ç¤ºJava课ç¨æ绩ã
ï¼2ï¼ç±»Student带åæ°çæé æ¹æ³ï¼
å¨æé æ¹æ³ä¸éè¿å½¢åå®æ对æååéçèµå¼æä½ã
ï¼3ï¼ç±»Studentçæ¹æ³æåï¼
getNoï¼ï¼ï¼è·å¾å¦å·ï¼
getNameï¼ï¼ï¼è·å¾å§åï¼
getSexï¼ï¼ï¼è·å¾æ§å«ï¼
getAgeï¼ï¼è·å¾å¹´é¾ï¼
getJavaï¼ï¼ï¼è·å¾Java 课ç¨æ绩
ï¼4ï¼æ ¹æ®ç±»Studentçå®ä¹ï¼å建äºä¸ªè¯¥ç±»ç对象ï¼è¾åºæ¯ä¸ªå¦ççä¿¡æ¯ï¼è®¡ç®å¹¶è¾åºè¿äºä¸ªå¦çJavaè¯è¨æ绩çå¹³åå¼ï¼ä»¥å计ç®å¹¶è¾åºä»ä»¬Javaè¯è¨æ绩çæ大å¼åæå°å¼ã*/
class student{
String sNO,sName,sSex;
int sAge;
double sJava;
public student(String a,String b,String c,int d ,double e){
sNO=a;
sName=b;
sSex=c;
sAge=d;
sJava=e;}
String getNo(){
return sNO;}
String getName(){
return sName;}
String getSex(){
return sSex;}
int getAge(){
return sAge;}
double getJava(){
return sJava;}
void show(){
System.out.println("å§å:"+getName());
System.out.println("å¦å·:"+getNo());
System.out.println("æ§å«:"+getSex());
System.out.println("å¹´é¾:"+getAge());
System.out.println("Javaæ绩:"+getJava());}
}
public class chengji{
public static void main(String[] args){
double avrage,K1,K2,K3,K4,K5;
student A1=new student("13190310","æä¸","ç·",18,80);
student A2=new student("13190311","åäº","女",19,83);
student A3=new student("13190312","å¼ ä¸","ç·",19,82);
student A4=new student("13190313","æ¨å","女",20,88);
student A5=new student("13190314","é©è","女",20,90);
A1.show();
System.out.println();
A2.show();
System.out.println();
A3.show();
System.out.println();
A4.show();
System.out.println();
A5.show();
System.out.println();
K1=A1.getJava();
K2=A2.getJava();
K3=A3.getJava();
K4=A4.getJava();
K5=A5.getJava();
avrage=(K1+K2+K4+K3+K5)/5;
System.out.println("Javaå¹³åæ绩:"+avrage);
double a[]={K1,K2,K3,K4,K5};
double max=0,min=0,ck;
for(int i=0;i<4;i++){
max=K1;
if(max<a[i+1]){
ck=max;
max=a[i+1];
a[i+1]=ck;} }
System.out.println("Javaçæé«å为:"+max);
for(int i=0;i<4;i++){
max=K1;
if(min>a[i+1]){
ck=min;
min=a[i+1];
a[i+1]=ck;}
}
System.out.println("Javaçæä½å为:"+max);
}
}
java:定义学生类Student, 其中属性有 name, id, score ,分别表示姓 ...
(1)类Student的成员变量:sNO 表示学号;sName表示姓名;sSex表示性别;sAge表示年龄;sJava:表示Java课程成绩。(2)类Student带参数的构造方法:在构造方法中通过形参完成对成员变量的赋值操作。(3)类Student的方法成员:getNo():获得学号;getName():获得姓名;getSex():获得性别;getAge...
JAVA编程 定义一个学生类,数据成员包括:学号,姓名,年龄,成绩;成员函数...
class Student{ String id;String name;int age;double score;public String getId() { return id;} public void setId(String id) { this.id = id;} public String getName() { return name;} public void setName(String name) { this.name = name;} public int getAge() { return ag...
一道java题 请设计一个学生类Student。属性包括:学号、姓名、英语成绩...
public class Student{ private String stuId; private String name; private float englishScore; private float mathScore; private float computerScore; private float sumScore; public Student() { } public Student(String stuId, String name, float englishScore, ...
用java写程序,定义一个student类,包含成员变量有学号、姓名、性别、班...
public class Student {\\x0d\\x0a\\x0d\\x0a\/**\\x0d\\x0a * @param args\\x0d\\x0a *\/\\x0d\\x0aboolean master; \/\/定义成员变量\\x0d\\x0aint num;\\x0d\\x0aString name,sex;\\x0d\\x0adouble math,chinese,english,score=0.0,average=0.0;\\x0d\\x0a\\x0d\\x0aStudent(int ...
用java创建一个学生类,包括学号,姓名,成绩,然后构造方法,初始化,输出...
public class Student {private String name;private String number;private int score;public Student() {}public Student(String name, String number, int score) {super();this.name = name;this.number = number;this.score = score;}public String getName() {return name;}public void set...
用java编程,设计一个学生类,要求包含姓名年龄、性别、java成绩、c++成 ...
public class Student{ private String name; private String sex; private int score_java; private int score_c; private int score_php; void averagescore() { int sum = 0; int average = 0; sum += score_java+score_c+score_php; average = sum\/3; ...
JAVA定义Student类:代表学生。其中有成员变量:姓名、年龄, 班级, 语文...
import java.math.BigDecimal;public class Student { private String name;private Integer age;private String clazz;private double chineseScore;private double mathScore;private double totalScore;public Student() { super();} public Student(String name, Integer age, String clazz, double chinese...
java定义一个Student类,包含内容如下
import java.util.*;public class Main { public static void main(String[] args) { \/\/ TODO Auto-generated method stub \/\/成员变量:学号、姓名、性别、班干部否、数学、语文、外语 Scanner scanner=new Scanner(System.in);System.out.println("输入学号");int id=scanner.nextInt();System....
java,设计一个学生类Student。用for语句的简化,属性包括:学号、姓名...
class Student{ private String sid; private Srting sname; private int k1; private int k2; private int k3; private avgScore; 分别获取其对应的get和set方法; public Student(){ } @override public String toString(){ }} ...
创建一个学生类,成员属性为学号,姓名,性别,年龄,java,成绩。成员属性通 ...
\/\/1、定义成员变量private String no;\/\/学号 private String name;\/\/姓名 private String sex;\/\/性别 private String age;\/\/年龄 private float score;\/\/成绩 \/\/2、通过构造方法初始化成员变量的值public Student(String no, String name, String sex, String age , float score) { this.no = ...