Advertisement
Spocoman

Fitness Center

Oct 9th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.99 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "bufio"
  5.     "fmt"
  6.     "os"
  7. )
  8.  
  9. func main() {
  10.     var visitors, back, chest, legs, abs, proteinBar, proteinShake int
  11.     fmt.Scanln(&visitors)
  12.    
  13.     var action string
  14.  
  15.     scanner := bufio.NewScanner(os.Stdin)
  16.    
  17.     for i := 0; i < visitors; i++ {
  18.         scanner.Scan()
  19.         action = scanner.Text()
  20.         switch action {
  21.         case "Back":
  22.             back++
  23.         case "Chest":
  24.             chest++
  25.         case "Legs":
  26.             legs++
  27.         case "Abs":
  28.             abs++
  29.         case "Protein bar":
  30.             proteinBar++
  31.         case "Protein shake":
  32.             proteinShake++
  33.         }
  34.     }
  35.  
  36.     fmt.Printf("%d - back\n%d - chest\n%d - legs\n%d - abs\n%d - protein shake\n%d - protein bar\n%.2f%% - work out\n%.2f%% - protein",
  37.                 back, chest, legs, abs, proteinShake, proteinBar, float64(back + chest + legs + abs) / float64(visitors) * 100, float64(proteinShake + proteinBar) / float64(visitors) * 100)
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement