Advertisement
Spocoman

Best Player

Oct 3rd, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.79 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var command, currentPlayer, bestPlayer string
  7.     var currentPlayerGoals, bestPlayerGoals int
  8.     fmt.Scanln(&command)
  9.    
  10.     for command != "END" {
  11.         currentPlayer = command
  12.         fmt.Scanln(&currentPlayerGoals)
  13.         if currentPlayerGoals > bestPlayerGoals {
  14.             bestPlayer = currentPlayer
  15.             bestPlayerGoals = currentPlayerGoals
  16.         }
  17.         if bestPlayerGoals >= 10 {
  18.           break
  19.         }
  20.         fmt.Scanln(&command)
  21.     }
  22.  
  23.     fmt.Printf("%s is the best player!\n", bestPlayer)
  24.  
  25.     if bestPlayerGoals < 3 {
  26.         fmt.Printf("He has scored %d goals.\n", bestPlayerGoals)
  27.     } else {
  28.         fmt.Printf("He has scored %d goals and made a hat-trick !!!\n", bestPlayerGoals)
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement