func gradeCalc(_ score: Int) -> String { switch score { case 0..<50: return "F" case 60..<70: return "D" case 70..<80: return "C" case 80..<90: return "B" case 90...100: return "A" default: return "Not a grade" } }
- func gradeCalc(_ score: Int) -> String {
(score < 0 || score > 100) ? "Not a grade" : ["F","F","F","F","F","F","D","C","B","A","A"][score / 10];}- switch score {
- case 0..<50:
- return "F"
- case 60..<70:
- return "D"
- case 70..<80:
- return "C"
- case 80..<90:
- return "B"
- case 90...100:
- return "A"
- default:
- return "Not a grade"
- }
- }