Advertisement
Spocoman

05. Pets

Sep 16th, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.52 KB | None | 0 0
  1. package main
  2. import (
  3.     "fmt"
  4.     "math"
  5. )
  6.  
  7. func main() {
  8.     var days, foodKg, dogKg, catKg, turtleGr float64
  9.     fmt.Scanln(&days)
  10.     fmt.Scanln(&foodKg)
  11.     fmt.Scanln(&dogKg)
  12.     fmt.Scanln(&catKg)
  13.     fmt.Scanln(&turtleGr)
  14.    
  15.     var totalKg = (dogKg + catKg + turtleGr / 1000) * days
  16.    
  17.     if (foodKg >= totalKg) {
  18.         fmt.Printf("%d kilos of food left.",(int)(foodKg - totalKg))
  19.     } else {
  20.             fmt.Printf("%d more kilos of food are needed.", (int)(math.Ceil(totalKg - foodKg)));
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement