教育路上
摘要:構造方法為成員變量賦值。以下是我們為大家整理的,相信大家閱讀完后肯定有了自己的選擇吧。
2022-12-02 16:16網絡推薦
package zhang7; import zhang7.student; public class test { public static void main(String[] args) { student.schoolname="重慶中學"; student s1=new student(); s1.setxx("zhangsan", 90.6f, 98.5f, 87.9f); s1.count(); System.out.println("zhangsan"+s1.schoolname +s1.getaverage()+s1.dengji()); } }
package zhang7; public class student { private String name; private float ywscore; private float sxscore; private float yyscore; static String schoolname; private float average; void setxx(String name,float ywscore,float sxscore,float yyscore) { this.name=name; this.ywscore=ywscore; this.sxscore=sxscore; this.yyscore=yyscore; } student(){ } student(String name,float ywscore,float sxscore,float yyscore){ this.name=name; this.ywscore=ywscore; this.sxscore=sxscore; this.yyscore=yyscore; } void count() { this.average=(ywscore+sxscore+yyscore)/3; } float getaverage() { return average; } String dengji() { String str=""; if(average>90) str="優秀"; else if(average>80) str="良好"; return str; } }
訪客的評論 2023/11/08 20:44
文中描述的是準確的嗎,如何報名!