Ask coding questions

← Back to all posts
switch statement
Triecie77 (2)

Create a property called testScore of type Int. Write a switch statement that will print out a grade based on the student's score.

Score Criteria
A+: 97%-100%
A: 93%-96%
A-: 90%-92%
B+: 87%-89%
B: 83%-86%
B-: 80%-82%
C+: 77%-79%
C: 73%-76%
C-: 70%-72%
D+: 67%-69%
D: 63%-66%
D: 60%-62%
F: 0%-59%
let testScore = 90...1

switch testScore {
case 0...59:
print("grade F")
case 60...69:
print("grade D && D+")
case 70...79:
print("grade C && C+")
case 80...89:
print("grade B && B+")
case 90...100:
print("grade A && A+")
print("All student's testScore")

Answered by theangryepicbanana (1636) [earned 5 cycles]
View Answer
Triecie77 (2)

Ok Im using swift language. So the challenge is to create a property called test Scores in Int. I have to use a switch statement that will print out a grade based on student's score.

theangryepicbanana (1636)

@Triecie77 ok well I don't really see a problem with your code. What is happening, and what are you wanting to happen instead?

Triecie77 (2)

@theangryepicbanana I thought it wanted me to print all testScores but I'm glad I'm on the right track