Advertisement
Spocoman

Cat Food

Oct 4th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.80 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var bedPrice, food, totalFood float64
  7.     fmt.Scanln(&bedPrice)
  8.    
  9.     var catCount, firstGroup, secondGroup, thirdGroup int
  10.     fmt.Scanln(&catCount)
  11.    
  12.     for i := 0; i < catCount; i++ {
  13.         fmt.Scanln(&food)
  14.         totalFood += food
  15.         if food >= 100 && food < 200 {
  16.             firstGroup++
  17.         } else if food >= 200 && food < 300 {
  18.             secondGroup++
  19.         } else if food >= 300 && food < 400 {
  20.             thirdGroup++
  21.         }
  22.     }
  23.  
  24.     priceForFoodPerDay := totalFood * 0.01245
  25.     fmt.Printf("Group 1: %d cats.\n", firstGroup)
  26.     fmt.Printf("Group 2: %d cats.\n", secondGroup)
  27.     fmt.Printf("Group 3: %d cats.\n", thirdGroup)
  28.     fmt.Printf("Price for food per day: %.2f lv.\n", priceForFoodPerDay)
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement