Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // controles switch1 switch.go
- package main
- import "fmt"
- func notaParaConceito(n float64) string {
- var nota = int(n)
- switch nota {
- case 10:
- fallthrough
- case 9:
- return "A"
- case 8, 7:
- return "B"
- case 6, 5:
- return "C"
- case 4, 3:
- return "D"
- case 2, 1, 0:
- return "E"
- default:
- return "Nota inválida"
- }
- }
- func main() {
- fmt.Println(notaParaConceito(9.8))
- fmt.Println(notaParaConceito(6.9))
- fmt.Println(notaParaConceito(2.1))
- fmt.Println(notaParaConceito(11.1))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement