A piano practice app scores each song: 90 or more earns 3 stars, 70 or more 2, 50 or more 1, below that none. Write stars_earned(scores, n) for the total stars over n songs. No songs gives 0.
stars_earned({95, 72, 40}, 3)→5stars_earned({50}, 1)→1int stars_earned(int scores[], int n)int stars_earned(int scores[], int n) {
int stars = 0;
for (int i = 0; i < n; i++) {
// your code here: by this score, add 3, 2, 1 or nothing to stars
}
return stars;
}
Run tries the examples. When they look right, Submit.