Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- var days, dailyDogFood, dailyCatFood, eatenDogsFood, eatenCatsFood int
- fmt.Scanln(&days)
- var availableFood, cookies float64
- fmt.Scanln(&availableFood)
- for i := 1; i <= days; i++ {
- fmt.Scanln(&dailyDogFood)
- fmt.Scanln(&dailyCatFood)
- if i % 3 == 0 {
- cookies += float64(dailyDogFood + dailyCatFood) * 0.1
- }
- eatenDogsFood += dailyDogFood
- eatenCatsFood += dailyCatFood
- }
- totalEatenFood := eatenDogsFood + eatenCatsFood
- fmt.Printf("Total eaten biscuits: %dgr.\n", int(math.Round(cookies)))
- fmt.Printf("%.2f%% of the food has been eaten.\n", float64(totalEatenFood) / float64(availableFood) * 100)
- fmt.Printf("%.2f%% eaten from the dog.\n", float64(eatenDogsFood) / float64(totalEatenFood) * 100)
- fmt.Printf("%.2f%% eaten from the cat.\n", float64(eatenCatsFood) / float64(totalEatenFood) * 100)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement