Rounding scores

Report a typo

Suppose you are a teacher at a primary school and need to grade your students' exams on a scale of integer values from 0 to 10.

Since the final grade can only be an integer value, you need to create a Go program that calculates the final grade by rounding it either up or down, depending on the number of decimals of the calculated score; for example:

If the exam has 25 questions and a student has 19 correct answers, their grade will be calculated with the following formula: 19 / 25 * 10 = 7.6. Afterward, you should use the appropriate rounding function from the math package to round the grade up, if the decimals are greater than or equal >= 0.5, or down, if the decimals are less than < 0.5. Finally, print the final grade.

Sample Input 1:

25
19

Sample Output 1:

8
Write a program in Go
package main

import (
"fmt"
"math"
)

const Precision = 10

func main() {
// Do not change the type of the variables from 'float64' to 'int'
var totalQuestions float64
fmt.Scanln(&totalQuestions)

var correctAnswers float64
fmt.Scanln(&correctAnswers)

// Please write the grading formula within the 'score' variable below:
score := ? / ? * Precision

// What function from the math package allows us
// to either round up or down based on the decimal numbers?
score = math.?(score)

fmt.Println(score)
}
___

Create a free account to access the full topic