Advertisement
Mushi

desafioSwitch.go

Apr 25th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.56 KB | None | 0 0
  1. // controles desafioSwitch desafioSwitch.go
  2. package main
  3.  
  4. import "fmt"
  5.  
  6. func notaParaConceito(n float64) string {
  7.     var nota = int(n)
  8.     switch {
  9.     case nota >= 9 && n <= 10:
  10.         return "A"
  11.     case nota >= 8 && n < 9:
  12.         return "B"
  13.     case nota >= 5 && n < 8:
  14.         return "C"
  15.     case nota >= 3 && n < 5:
  16.         return "D"
  17.     case nota >= 0 && n < 3:
  18.         return "E"
  19.     default:
  20.         return "Nota inválida"
  21.     }
  22.  
  23. }
  24.  
  25. func main() {
  26.     fmt.Println(notaParaConceito(9.8))
  27.     fmt.Println(notaParaConceito(6.9))
  28.     fmt.Println(notaParaConceito(2.1))
  29.     fmt.Println(notaParaConceito(11.1))
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement