Advertisement
Spocoman

Cat Shelter

Oct 4th, 2024
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.56 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "strconv"
  6. )
  7.  
  8. func main() {
  9.     var foodKg, foodEaten int
  10.     fmt.Scanln(&foodKg)
  11.  
  12.     foodGrams := foodKg * 1000
  13.  
  14.     var command string
  15.     fmt.Scanln(&command)
  16.    
  17.     for command != "Adopted" {
  18.         foodEaten, _ = strconv.Atoi(command)
  19.         foodGrams -= foodEaten
  20.         fmt.Scanln(&command)
  21.     }
  22.  
  23.     if foodGrams >= 0 {
  24.         fmt.Printf("Food is enough! Leftovers: %d grams.\n", foodGrams)
  25.     } else {
  26.         fmt.Printf("Food is not enough. You need %d grams more.\n", foodGrams * -1)
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement