Reputation:
I have 3 variables that are inside a quiz and at the end of the quiz, 1 of those variables is going to be higher than the other ones, but it could also be that 1 of those variable has the exact value as another variable, or even that the 3 variables have exactly the same value. What function could i run to read those three variables and print the answer? (The problem im having is that it sometimes reads two variables that have the same value and prints that as the answer, while one variable is higher than those other two)
Im putting here the code im trying to do it with but it's not working with it
var VFinal = 9
var AFinal = 5
var KFinal = 5
var resultText = ""
func finalResultText() {
if VFinal > KFinal && VFinal > AFinal {
resultText = "Visual, Auditive and Kinesthetic"
} else if KFinal > VFinal && KFinal > AFinal {
resultText = "Visual and Auditive"
} else if AFinal > VFinal && AFinal > KFinal {
resultText = "Visual and Kinesthetic"
} else if KFinal == AFinal {
resultText = "Auditive and Kinesthetic"
} else if AFinal == VFinal {
resultText = "Kinesthetic"
} else if VFinal == KFinal {
resultText = "Auditive"
} else if AFinal == VFinal && AFinal == KFinal {
resultText = "Visual"
}
}
Upvotes: 0
Views: 91
Reputation: 333
var VFinal = 5
var AFinal = 5
var KFinal = 5
func finalResultText() {
if KFinal > VFinal && KFinal > AFinal {
print("Kinesthetic")
} else if AFinal > VFinal && AFinal > KFinal {
print("Auditive")
} else if VFinal > KFinal && VFinal > AFinal {
print("Visual")
} else if AFinal == VFinal && AFinal == KFinal {
print("Visual, Auditive and Kinesthetic")
} else if AFinal == VFinal {
print("Visual and Auditive")
} else if VFinal == KFinal {
print("Visual and Kinesthetic")
} else if KFinal == AFinal {
print("Auditive and Kinesthetic")
}
}
Upvotes: 1