Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- )
- func main() {
- var visitors, back, chest, legs, abs, proteinBar, proteinShake int
- fmt.Scanln(&visitors)
- var action string
- scanner := bufio.NewScanner(os.Stdin)
- for i := 0; i < visitors; i++ {
- scanner.Scan()
- action = scanner.Text()
- switch action {
- case "Back":
- back++
- case "Chest":
- chest++
- case "Legs":
- legs++
- case "Abs":
- abs++
- case "Protein bar":
- proteinBar++
- case "Protein shake":
- proteinShake++
- }
- }
- 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",
- back, chest, legs, abs, proteinShake, proteinBar, float64(back + chest + legs + abs) / float64(visitors) * 100, float64(proteinShake + proteinBar) / float64(visitors) * 100)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement