答案:
import javax.swing.JOptionPane;
public class Student {
private static String name;
private static String id;
private float chinese;
private float math;
private float english;
public Student(String name, String id){
this.name="张三";
this.id=id;
}
public float average(){
float avg=(chinese+math+english)/3;
if(avg>90.0){
System.out.println("属于三好学生");
}
else{
System.out.println("不属于三好学生");
}
return avg;
}
public float score(){
return(chinese+math+english);
}
public boolean goodstudent(){
float avg=average();
return avg>90.0;
}
public String setName(){
return this.name=name;
}
public String getName(){
return name;
}
public void steId(String id){
this.id=id;
}
//public float getChinese(){
// return chinese;
//}
public void setChinese(float chinese){
this.chinese=chinese;
}
public float getMath(){
return math;
}
public void setMath(float math){
this.math=math;
}
public float getEnglish(){
return english;
}
public void setEnglish(float english){
this.english=english;
}
//public String totring(){
// return"当前学生信息为:[姓名="+name+",学号="+id+",语文成绩="+chinese+",数学成绩="+math+",英语成绩="+english+"]";
// }
public static void main(String[]args){
// StudentDemo a=new StudentDemo();
//StudentDemo b=new StudentDemo();
String chinese = JOptionPane.showInputDialog(null,"考试成绩","语文",1);
String math = JOptionPane.showInputDialog(null,"考试成绩","数学",1);
String english= JOptionPane.showInputDialog(null,"考试成绩","英语",1);
double a=Integer.parseInt(chinese);
double b=Integer.parseInt(math);
double c=Integer.parseInt(english);
double score=a+b+c;
Student s=new Student(name,id);
System.out.println("姓名: wang");
System.out.println("语文成绩 "+chinese);
System.out.println("数学成绩 "+math);
System.out.println("英语成绩 "+english);
//System.out.println("姓名: "+a.getName());
//System.out.println("学号: "+b.getId());
System.out.println("总成绩: "+score);
//System.out.println("平均成绩:"+s.score());
if(a+b+c>=270)
{
System.out.print("该同学是三好学生");
}
}
}