Professional Documents
Culture Documents
01-Programs - StudentGrade
01-Programs - StudentGrade
1 $vi StudentTester.java
1 class Student {
2
3 String name;
4 int age;
5 float t1, t2, compre, total;
6
7 char grade;
8
9 public Student ( String n, int a) {name = n; age = a;}
1
0
1
public void setT1 (float aT1) { t1 = aT1; }
1 public void setT2 (float aT2) { t2 = aT2; }
1 public void setCompre (float aCompre) { compre = aCompre; }
2
1
3 public void calcTotal() { total = t1 + t2 + compre; }
1 public float getTotal() { return total; }
4
public void calcGrade(float cutOffA, float cutOffB, float cutOffC) {
if ( total >= cutOffA ) { grade = 'A';
} else if ( total >= cutOffB ) { grade = 'B';
} else if ( total >= cutOffC ) { grade = 'C';
} else { grade = 'D';
}
}
$java StudentTester