Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student {
- public String studentName;
- public int[] grades;
- public Student(String studentName, int[] grades){
- this.studentName = studentName;
- this.grades = grades;
- }
- public void displayInfo(){
- System.out.println("Student: name: " + studentName + ", Grades:");
- for (int grade : grades) {
- System.out.println(grade + " ");
- }
- System.out.println();
- }
- public int calcAverage() {
- int total = 0;
- for(int grade : grades) {
- total += grade;
- }
- return (double) total / grades.length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement