Created
August 24, 2017 04:29
-
-
Save alecGraves/d5ab8f1c669a821e244f0a26ca6f65d1 to your computer and use it in GitHub Desktop.
Tiny Student Struct for MTRE 2610
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Student { | |
int n, c[9], g[9]; | |
void SetGrades(int *C, char *G, int N){ | |
for (int i(0); i < N; ++i){ | |
AddGrade(C[i], G[i]); | |
} | |
} | |
void AddGrade(int C, char G){ | |
c[n] = C; | |
g[n++] = G; | |
} | |
double GetGPA(){ | |
int h(0), w(0); | |
for (int i(0); i < n; ++i){ | |
if(g[i] < 69) w += (69-g[i])*c[i]; | |
h += c[i]; | |
} | |
return (float)w / h; | |
} | |
Student() :n(0) {} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment