Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- const easterBreadPrice = 4.00
- const eggPrice = 0.45
- var guests int
- fmt.Scanln(&guests)
- var budget float64
- fmt.Scanln(&budget)
- neededEasterbreads := int(math.Ceil(float64(guests) / 3))
- neededEggs := guests * 2
- budget -= easterBreadPrice * float64(neededEasterbreads) + eggPrice * float64(neededEggs)
- if budget < 0 {
- fmt.Printf("Lyubo doesn't have enough money.\nHe needs %.2f lv. more.", math.Abs(budget))
- } else {
- fmt.Printf("Lyubo bought %d Easter bread and %d eggs.\nHe has %.2f lv. left.", neededEasterbreads, neededEggs, budget)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement