Combine variables and arithmetic to compute a student's weighted final score.
Weights: Homework 20%, Midterm 30%, Final 50%. Each weighted part is rounded down to a whole number before the parts are added.
You start with:
homework := 90
midterm := 82
finalExam := 88
score := homework * 20 / 100 + midterm * 30 / 100 + finalExam * 50 / 100
fmt.Println("Score: " + strconv.Itoa(score))
Build:
Score: 86
Rules:
- Compute
score = homework * 20 / 100 + midterm * 30 / 100 + finalExam * 50 / 100. - Each part is rounded down because
intdivided byintdrops the remainder (the third variable is namedfinalExam). - For the starting data: 18 + 24 + 44 = 86.
- Print
"Score: "followed by the score; usestrconv.Itoa(...)to join an integer to a string.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
