Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var n, number int
- fmt.Scanln(&n)
- totalGrades := 0.0
- totalCredits := 0.0
- for i := 0; i < n; i++ {
- fmt.Scanln(&number)
- grade := number % 10
- credit := number / 10
- totalGrades += float64(grade)
- if grade == 3 {
- totalCredits += float64(credit) * 0.50
- } else if grade == 4 {
- totalCredits += float64(credit) * 0.70
- } else if grade == 5 {
- totalCredits += float64(credit) * 0.85
- } else if grade == 6 {
- totalCredits += float64(credit)
- }
- }
- fmt.Printf("%.2f\n%.2f\n", totalCredits, totalGrades / float64(n))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement