Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- "strconv"
- )
- func main() {
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- gamer := scanner.Text()
- scanner.Scan()
- games, _ := strconv.Atoi(scanner.Text())
- var score, volleyballGames, tennisGames, badmintonGames int
- var volleyballScores, tennisScores, badmintonScores float64
- var game string
- for i := 0; i < games; i++ {
- scanner.Scan()
- game = scanner.Text()
- scanner.Scan()
- score, _ = strconv.Atoi(scanner.Text())
- if game == "volleyball" {
- volleyballGames++
- volleyballScores += float64(score) * 1.07
- } else if game == "tennis" {
- tennisGames++
- tennisScores += float64(score) * 1.05
- } else {
- badmintonGames++
- badmintonScores += float64(score) * 1.02
- }
- }
- averageVolleyballPoints := int(volleyballScores / float64(volleyballGames))
- averageTennisPoints := int(tennisScores / float64(tennisGames))
- averageBadmintonPoints := int(badmintonScores / float64(badmintonGames))
- totalPoints := int(volleyballScores + tennisScores + float64(badmintonScores))
- if averageVolleyballPoints >= 75 && averageTennisPoints >= 75 && averageBadmintonPoints >= 75 {
- fmt.Printf("Congratulations, %s! You won the cruise games with %d points.", gamer, totalPoints)
- } else {
- fmt.Printf("Sorry, %s, you lost. Your points are only %d.", gamer, totalPoints)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement