Skip to content

Instantly share code, notes, and snippets.

@dzsquared
Created January 1, 2017 22:43
Show Gist options
  • Save dzsquared/05d44d4e0b164f7fc022ee167d75d443 to your computer and use it in GitHub Desktop.
Save dzsquared/05d44d4e0b164f7fc022ee167d75d443 to your computer and use it in GitHub Desktop.
class Student : Person{
private int[] testScores;
public Student(string firstName, string lastName, int identification, int[] scores) {
this.firstName = firstName;
this.lastName = lastName;
this.id = identification;
this.testScores = scores;
}
public string calculate() {
double totalScore = 0;
string returnLetter;
for(int j = 0; j < testScores.Length; j++) {
totalScore += testScores[j];
}
if(totalScore/(testScores.Length) >= 90) {
returnLetter = "O";
} else if(totalScore/(testScores.Length) < 90 && totalScore/(testScores.Length) >= 80) {
returnLetter = "E";
} else if(totalScore/(testScores.Length) < 80 && totalScore/(testScores.Length) >= 70) {
returnLetter = "A";
} else if(totalScore/(testScores.Length) < 70 && totalScore/(testScores.Length) >= 55) {
returnLetter = "P";
} else if(totalScore/(testScores.Length) < 55 && totalScore/(testScores.Length) >= 40) {
returnLetter = "D";
} else {
returnLetter = "T";
}
return returnLetter;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment