Advertisement
Spocoman

Cruise Games

Oct 6th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.55 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "bufio"
  6.   "os"
  7.   "strconv"
  8. )
  9.  
  10. func main() {
  11.     scanner := bufio.NewScanner(os.Stdin)
  12.     scanner.Scan()
  13.     gamer := scanner.Text()
  14.  
  15.     scanner.Scan()
  16.     games, _ := strconv.Atoi(scanner.Text())  
  17.    
  18.     var score, volleyballGames, tennisGames, badmintonGames int
  19.     var volleyballScores, tennisScores, badmintonScores float64
  20.     var game string
  21.    
  22.     for i := 0; i < games; i++ {
  23.         scanner.Scan()
  24.         game = scanner.Text()
  25.        
  26.         scanner.Scan()
  27.         score, _ = strconv.Atoi(scanner.Text())
  28.        
  29.         if game == "volleyball" {
  30.             volleyballGames++
  31.             volleyballScores += float64(score) * 1.07
  32.         } else if game == "tennis" {
  33.             tennisGames++
  34.             tennisScores += float64(score) * 1.05
  35.         } else {
  36.             badmintonGames++
  37.             badmintonScores += float64(score) * 1.02
  38.         }
  39.     }
  40.  
  41.     averageVolleyballPoints := int(volleyballScores / float64(volleyballGames))
  42.     averageTennisPoints := int(tennisScores / float64(tennisGames))
  43.     averageBadmintonPoints := int(badmintonScores / float64(badmintonGames))
  44.     totalPoints := int(volleyballScores + tennisScores + float64(badmintonScores))
  45.  
  46.     if averageVolleyballPoints >= 75 && averageTennisPoints >= 75 && averageBadmintonPoints >= 75 {
  47.         fmt.Printf("Congratulations, %s! You won the cruise games with %d points.", gamer, totalPoints)
  48.     } else {
  49.         fmt.Printf("Sorry, %s, you lost. Your points are only %d.", gamer, totalPoints)
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement