Advertisement
Spocoman

Credit System

Oct 6th, 2024
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.72 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var n, number int
  7.     fmt.Scanln(&n)
  8.    
  9.     totalGrades := 0.0
  10.     totalCredits := 0.0
  11.  
  12.     for i := 0; i < n; i++ {
  13.         fmt.Scanln(&number)
  14.        
  15.         grade := number % 10
  16.         credit := number / 10
  17.  
  18.         totalGrades += float64(grade)
  19.  
  20.         if grade == 3 {
  21.             totalCredits += float64(credit) * 0.50
  22.         } else if grade == 4 {
  23.             totalCredits += float64(credit) * 0.70
  24.         } else if grade == 5 {
  25.             totalCredits += float64(credit) * 0.85
  26.         } else if grade == 6 {
  27.             totalCredits += float64(credit)
  28.         }
  29.     }
  30.  
  31.     fmt.Printf("%.2f\n%.2f\n", totalCredits, totalGrades / float64(n))
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement