Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "strconv"
- )
- func main() {
- var foodInKilograms int
- fmt.Scanln(&foodInKilograms)
- availableFoodInGrams := foodInKilograms * 1000
- var command string
- fmt.Scanln(&command)
- for command != "Adopted" {
- foodEaten, _ := strconv.Atoi(command)
- availableFoodInGrams -= foodEaten
- fmt.Scanln(&command)
- }
- if availableFoodInGrams >= 0 {
- fmt.Printf("Food is enough! Leftovers: %d grams.", availableFoodInGrams)
- } else {
- fmt.Printf("Food is not enough. You need %d grams more.", availableFoodInGrams * -1)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement