教育路上
摘要:构造方法为成员变量赋值。以下是我们为大家整理的,相信大家阅读完后肯定有了自己的选择吧。
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/12/09 20:15
文中描述的是准确的吗,如何报名!