Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var badGrades int
- fmt.Scanln(&badGrades)
- var task string
- fmt.Scanln(&task)
- var lastProblem = ""
- var badGradesCounter = 0
- var tasksCount = 0
- var grade float64
- var sumGrades = 0.0
- for ; badGradesCounter != badGrades && task != "Enough"; {
- fmt.Scanln(&grade)
- if (grade <= 4) {
- badGradesCounter++
- }
- sumGrades += grade
- lastProblem = task
- tasksCount++
- fmt.Scanln(&task)
- }
- if badGradesCounter == badGrades {
- fmt.Printf("You need a break, %d poor grades.\n", badGrades)
- } else {
- fmt.Printf("Average score: %.2f\n", sumGrades / float64(tasksCount))
- fmt.Printf("Number of problems: %d\n", tasksCount)
- fmt.Printf("Last problem: %s\n", lastProblem)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement