1
Can help me improve this little code so it’s less extensive and clean?
The code compares three numbers and shows which and the largest among them:
@IBAction func comprar(_ sender: Any) {
if pNumero.text! > sNumero.text! {
messageLabel.text = "Primeiro número e maior"
}
else if pNumero.text! < sNumero.text! {
messageLabel.text = "Segundo número e maior"
}
if tNumero.text! > pNumero.text!{
messageLabel.text = "o Terceiro número e maior"
}
else if tNumero.text! < sNumero.text! {
messageLabel.text = "o Terceiro número e maior"
}
else if pNumero.text! == sNumero.text!{
messageLabel.text = "Os dois números são iguais"
}
Ai Anderson, thanks for the help. The idea is, the user will enter 3 numbers and the if and Else analyze which is the largest number of the three. * Now I think of a condition that says which is the highest number and best of the three inserted
– An. Jorge
Best of three?
– Woss
Greater number of the three
– An. Jorge
https://repl.it/F50n/0, see here working.
– Woss
Worked perfectly!
– An. Jorge
Mark the answer as valid, if possible.
– Woss
Done !!!!!!!!!!
– An. Jorge