vkorbes / aprendago

Curso completo em português da linguagem Go, de zero a ninja! 🇧🇷
http://aprendago.com
1.03k stars 183 forks source link

Exercício: Capítulo 7, Exercício 7 (Nível: 3) #23

Open vkorbes opened 4 years ago

vkorbes commented 4 years ago

Exercício: Capítulo 7, Exercício 7 (Nível: 3)

Link para o vídeo:

Use esta thread para compartilhar sua solução, discutir o exercício com os colegas e pedir ajuda caso tenha dificuldades!

diegoparra commented 4 years ago

https://play.golang.org/p/4xGvuraDNTC

thiagoalgo commented 3 years ago

https://play.golang.org/p/XHcq9UXLtJs

viniciussanchez commented 3 years ago

https://play.golang.org/p/-EDl6Cml38n

tomxdev commented 3 years ago
package main

import "fmt"

func main() {
    isValid := 2
    if isValid == 0 {
        fmt.Println("status 0")
    }else if isValid == 1 {
        fmt.Println("status 1")
    }else {
        fmt.Println("status inválido")
    }
}
an4kein commented 3 years ago

https://play.golang.org/p/-J0H_0SRrMu

ygorsimoes commented 3 years ago
JPauloMoura commented 3 years ago
package main

//Utilizando a solução anterior, adicione as opções else if e else.
import "fmt"

func main() {
    if eDomingo := true; eDomingo {
        fmt.Print("Bom dia! Hoje é Domingo dia de descansar!")
    } else {
        fmt.Print("Bom dia! Tenho que trabalhar duro hoje!")
    }
}

Resolução do Exercício

Lucasmirandar commented 3 years ago

package main

import "fmt"

func main() { x := 10 if x < 10 { fmt.Println("X < 10") } else if x == 10 { fmt.Println("X = 10") } else { fmt.Println("X > 10") } }

CarlosSMA commented 2 years ago
package main

import (
    "fmt"
)

func main() {
    numero1 := 2
    numero2 := 3
    numero3 := 4

    for i := 1; i <= 10; i++ {
        if i%numero1 == 0 {
            fmt.Println("Número", i, " é divisível por 2")
        }
        if i%numero2 == 0 {
            fmt.Println("Número", i, " é divisível por 3")
        }
        if i%numero3 == 0 {
            fmt.Println("Número", i, " é divisível por 4")
        }

        if !(i%numero1 == 0) && !(i%numero2 == 0) && !(i%numero3 == 0) {
            fmt.Println("Número", i, " não é divisível por 2, 3 ou 4")
        } else if i%numero1 == 0 {
            fmt.Println("Número", i, " é divisível por 2 (2)")
        } else {
            fmt.Println("Numéro", i, " é divisível por 3 ou 4")
        }
    }
}

Saída

Número 1  não é divisível por 2, 3 ou 4
Número 2  é divisível por 2
Número 2  é divisível por 2 (2)
Número 3  é divisível por 3
Numéro 3  é divisível por 3 ou 4
[...]
CaueFarias commented 2 years ago

https://go.dev/play/p/B2tye_aStOT

wfrsilva commented 2 years ago

https://go.dev/play/p/2j1rnyTzcpS

image

M3L1M commented 1 year ago

s := "Gabriel"

if s == "Gabriel" {
    fmt.Println("Que nome legal")
} else if s == "Marquinhos" {
    fmt.Println("Que nome meia boca")
} else {
    fmt.Println("Blz, pare de tentar, o seu nome não é legal")
}
adelsonsljunior commented 1 year ago
package main

import (
    "fmt"
)

func main() {

    numero := 3

    if numero == 1 {
        fmt.Println("É 1!")
    } else if numero == 2 {
        fmt.Println("É 2!")
    } else {
        fmt.Println("É um número aleatório!")
    }

}
hiercj commented 5 months ago

https://www.onlinegdb.com/fork/U88xkuF_J

DominMFD commented 4 months ago

https://go.dev/play/p/5abujcTuBNm

Vitor-Zen commented 3 months ago

https://go.dev/play/p/NgiyHetfiM2