0

Can you explain the last part of this question?

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. Note: I will post my program in the comments section.

4th Sep 2021, 4:27 PM
Uppili OMS
6 ответов
+ 3
I don't know anything about go or this code but from what i understand , it is asking to take an input and append it to existing array . Later sum all of the array based on w , l or d.
4th Sep 2021, 4:33 PM
Abhay
Abhay - avatar
+ 1
Uppili OMS You didn't take that input num which should be append in array so do this: var num string fmt.Scanln(&num) total := 0 results = append(results, num) Rest code is ok.
4th Sep 2021, 4:40 PM
A͢J
A͢J - avatar
0
package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} total := 0 results = append(results, results[num]) for _,val:= range results { switch val { case "w": total += 3; break; case "l": break; default: total += 1; break; } } fmt.Println(total) } This is my code.
4th Sep 2021, 4:28 PM
Uppili OMS
0
They had asked to take an User Input and append to the array ?
4th Sep 2021, 4:35 PM
Uppili OMS
0
Uppili OMS right .You can try it and if that doesn't works then i am sorry !
4th Sep 2021, 4:41 PM
Abhay
Abhay - avatar
0
It did indeed work bro, Thanks 👍
4th Sep 2021, 4:43 PM
Uppili OMS