aprendago icon indicating copy to clipboard operation
aprendago copied to clipboard

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

Open vkorbes opened this issue 4 years ago • 16 comments

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!

vkorbes avatar Sep 30 '20 17:09 vkorbes

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

diegoparra avatar Oct 06 '20 01:10 diegoparra

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

thiagoalgo avatar Jan 10 '21 18:01 thiagoalgo

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

viniciussanchez avatar Jan 15 '21 14:01 viniciussanchez

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")
	}
}

tomxdev avatar Feb 03 '21 10:02 tomxdev

  • Utilizando a solução anterior, adicione as opções else if e else.

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

an4kein avatar Feb 10 '21 01:02 an4kein

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

JPauloMoura avatar May 27 '21 01:05 JPauloMoura

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") } }

Lucasmirandar avatar Jun 08 '21 11:06 Lucasmirandar

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
[...]

CarlosSMA avatar Dec 21 '21 17:12 CarlosSMA

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

CaueFarias avatar Feb 17 '22 13:02 CaueFarias

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

image

wfrsilva avatar May 26 '22 03:05 wfrsilva

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")
}

M3L1M avatar Feb 11 '23 04:02 M3L1M

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!")
	}

}

adelsonsljunior avatar May 13 '23 14:05 adelsonsljunior

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

mrercj avatar Apr 21 '24 02:04 mrercj

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

DominMFD avatar May 14 '24 13:05 DominMFD

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

Vitor-Zen avatar Jul 01 '24 12:07 Vitor-Zen