Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var modelCount, model, rating, sales int
- fmt.Scanln(&modelCount)
- var totalSales, totalRating float64
- for i := 0; i < modelCount; i++ {
- fmt.Scanln(&model)
- rating = model % 10
- sales = model / 10
- totalRating += float64(rating)
- switch rating {
- case 2:
- totalSales += float64(sales) * 0
- case 3:
- totalSales += float64(sales) * 0.5
- case 4:
- totalSales += float64(sales) * 0.7
- case 5:
- totalSales += float64(sales) * 0.85
- default:
- totalSales += float64(sales)
- }
- }
- fmt.Printf("%.2f\n%.2f\n", totalSales, totalRating / float64(modelCount))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement