Skip to content

Instantly share code, notes, and snippets.

@ayeshLK
Created January 4, 2022 19:25
Show Gist options
  • Save ayeshLK/5178dd6e8906c548b8808cbbabc0f237 to your computer and use it in GitHub Desktop.
Save ayeshLK/5178dd6e8906c548b8808cbbabc0f237 to your computer and use it in GitHub Desktop.
enum Grade {
A, B, C, F
}
function calculateGrade(int marks) returns Grade {
// checks whether the `marks` are greater than or equal to `75`
if marks >= 75 {
return A;
// checks whether the `marks` are less than `75` but greater than or equal to `65`
} else if marks >= 65 {
return B;
// checks whether the `marks` are less than `65` but greater than or equal to `40`
} else if marks >= 40 {
return C;
} else {
return F;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment