Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var availableEggs, eggs, soldEggs int
- fmt.Scanln(&availableEggs)
- var input string
- fmt.Scanln(&input)
- for input != "Close" {
- fmt.Scanln(&eggs)
- if input == "Buy" {
- if availableEggs - eggs < 0 {
- break
- }
- availableEggs -= eggs
- soldEggs += eggs
- } else if input == "Fill" {
- availableEggs += eggs
- }
- fmt.Scanln(&input)
- }
- if input == "Close" {
- fmt.Printf("Store is closed!\n%d eggs sold.\n", soldEggs)
- } else {
- fmt.Printf("Not enough eggs in store!\nYou can buy only %d.\n", availableEggs)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement