Advertisement
Spocoman

07. Football League

Sep 21st, 2024
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.00 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var stadiumCapacity, footballFans int
  7.     fmt.Scanln(&stadiumCapacity)
  8.     fmt.Scanln(&footballFans)
  9.    
  10.     var sectorA = 0
  11.     var sectorB = 0
  12.     var sectorV = 0
  13.     var sectorG = 0
  14.  
  15.     var sector string
  16.    
  17.     for i := 0; i < footballFans; i++ {
  18.         fmt.Scanln(&sector)
  19.         switch (sector) {
  20.                 case "A":
  21.                     sectorA++
  22.                 case "B":
  23.                     sectorB++
  24.                 case "V":
  25.                     sectorV++
  26.                 case "G":
  27.                     sectorG++
  28.         }
  29.     }
  30.  
  31.     fmt.Printf("%.2f%%\n", float64(sectorA) / float64(footballFans) * 100.0)
  32.     fmt.Printf("%.2f%%\n", float64(sectorB) / float64(footballFans) * 100.0)
  33.     fmt.Printf("%.2f%%\n", float64(sectorV) / float64(footballFans) * 100.0)
  34.     fmt.Printf("%.2f%%\n", float64(sectorG) / float64(footballFans) * 100.0)
  35.     fmt.Printf("%.2f%%\n", float64(footballFans) / float64(stadiumCapacity) * 100)
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement