0

Go..math result

You are making a program to analyze sport match results and calculate the points of the given team. The match results are stored in an array called results. Each match has one of the following results: "w" - won "l" - lost "d" - draw A win adds three points, a draw adds one point, and a lost match does not add any points. Your program needs to take the last match result as input and append it to the results array. After that, calculate and output the total points the team gained from the results. Pls help me out...I am stuck

15th Aug 2021, 6:25 PM
Ejeh Wayne
Ejeh Wayne - avatar
2 Respuestas
+ 4
Ejeh Wayne , to get useful help from the community,  we need to see your attempt first. without having seen your code, it is difficult to find out where the issue is. => please put your code in playground and link it here thanks!
15th Aug 2021, 7:10 PM
Lothar
Lothar - avatar
+ 1
/* Good luck */ package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} var res int var input string fmt.Scanln(&input) results = append(results, input) for _, v := range results { switch { case v == "w": res += 3 case v == "d": res += 1 } } fmt.Println(res) } /* Thank you me ::)) */
17th Aug 2022, 6:09 PM
Muzaffar Bekturdiyev