Advertisement
Spocoman

Computer Firm

Oct 5th, 2024 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.81 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var modelCount, model, rating, sales int
  7.     fmt.Scanln(&modelCount)
  8.    
  9.     var totalSales, totalRating float64
  10.  
  11.     for i := 0; i < modelCount; i++ {
  12.         fmt.Scanln(&model)
  13.         rating = model % 10
  14.         sales = model / 10
  15.         totalRating += float64(rating)
  16.  
  17.         switch rating {
  18.             case 2:
  19.                 totalSales += float64(sales) * 0
  20.             case 3:
  21.                 totalSales += float64(sales) * 0.5
  22.             case 4:
  23.                 totalSales += float64(sales) * 0.7
  24.             case 5:
  25.                 totalSales += float64(sales) * 0.85
  26.             default:
  27.                 totalSales += float64(sales)
  28.         }
  29.     }
  30.  
  31.     fmt.Printf("%.2f\n%.2f\n", totalSales, totalRating / float64(modelCount))
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement