Advertisement
Spocoman

Care of Puppy

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