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