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
2 Réponses
+ 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!
+ 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 ::)) */