Advertisement
Mushi

switch1.go

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