1 public class stuwenjian { 2 public int Yuwen; 3 public int Shuxue; 4 public int Yingyu; 5 6 public stuwenjian() 7 { 8 System.out.println("成绩查询。。。"); 9 } 10 int zongf; 11 double pingjf; 12 public stuwenjian(int 语文, int 数学, int 英语) 13 { 14 Yuwen = 语文; 15 Shuxue = 数学; 16 Yingyu = 英语; 17 } 18 public void js(int a, int b, int c) 19 { 20 zongf = a+b+c; 21 pingjf = (double)zongf/3; 22 if( a>=60 && b>=60 && c>=60 && zongf>180 && pingjf>60 ) 23 { 24 System.out.println("已通过了这次考试"); 25 System.out.println("语文 "+a+",数学 "+b+",英语 "+c); 26 System.out.println("总分为:"+zongf+"\n平均分为:"+pingjf); 27 } 28 else 29 { 30 System.out.println("请联系班主任进行补考"); 31 } 32 33 if(a<60) 34 { 35 System.out.println("未及格的语文成绩为 "+a); 36 } 37 else if(b<60) 38 { 39 System.out.println("未及格的数学成绩为 "+b); 40 } 41 else if(c<60) 42 { 43 System.out.println("未及格的英语成绩为 "+c); 44 } 78 } 79 80 }
1 public class cjcx { 2 3 public static void main(String[] args) { 4 try 5 { 6 stuwenjian xiaoming = new stuwenjian(67, 57, 81); 7 xiaoming.js(67, 57, 81); 8 System.out.println("数学成绩:"+xiaoming.Shuxue); //xiaoming名为Shuxue的属性 9 System.out.println("英语成绩:"+xiaoming.Yingyu); 10 System.out.println("语文成绩:"+xiaoming.Yuwen); 11 System.out.println(); 12 stuwenjian xiaohong = new stuwenjian(90, 96, 89); 13 xiaohong.js(90, 96, 89); 14 } 15 catch(Exception e) 16 { 17 System.out.println("请输入正确的分数"); 18 } 19 } 20 21 }