Graderpractice for programmers

Back to 273387 MAD 63 - C5 Classes

D. Average grade

Problem

Write a function that returns the student's average grade (as a Float).

let peter = Student(id: 5, firstName: "Peter", lastName: "Parker")
peter.addGrade(2.95)
peter.addGrade(3.45)
print("Average: \(peter.average())")    // Prints "Average: 3.2"

Examples

Submit your solution

swift