Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var students int
- fmt.Scanln(&students)
- var grade3 = 0.0
- var grade4 = 0.0
- var grade5 = 0.0
- var grade6 = 0.0
- var gradeSum = 0.0
- var grade float64
- for i := 0; i < students; i++ {
- fmt.Scanln(&grade)
- if grade >= 5 {
- grade6++
- } else if grade >= 4 {
- grade5++
- } else if grade >= 3 {
- grade4++
- } else if grade >= 2 {
- grade3++
- }
- gradeSum += grade
- }
- fmt.Printf("Top students: %.2f%%\n", grade6 / float64(students) * 100.0)
- fmt.Printf("Between 4.00 and 4.99: %.2f%%\n", grade5 / float64(students) * 100.0)
- fmt.Printf("Between 3.00 and 3.99: %.2f%%\n", grade4 / float64(students) * 100.0)
- fmt.Printf("Fail: %.2f%%\n", grade3 / float64(students) * 100.0)
- fmt.Printf("Average: %.2f\n", gradeSum / float64(students))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement