Advertisement
Spocoman

Easter Guests

Oct 8th, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.69 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "math"
  6. )
  7.  
  8. func main() {
  9.     const easterBreadPrice = 4.00
  10.     const eggPrice = 0.45
  11.    
  12.     var guests int
  13.     fmt.Scanln(&guests)
  14.    
  15.     var budget float64
  16.     fmt.Scanln(&budget)
  17.    
  18.     neededEasterbreads := int(math.Ceil(float64(guests) / 3))
  19.     neededEggs := guests * 2
  20.    
  21.     budget -= easterBreadPrice * float64(neededEasterbreads) + eggPrice * float64(neededEggs)  
  22.  
  23.     if budget < 0 {
  24.         fmt.Printf("Lyubo doesn't have enough money.\nHe needs %.2f lv. more.", math.Abs(budget))
  25.     } else {
  26.         fmt.Printf("Lyubo bought %d Easter bread and %d eggs.\nHe has %.2f lv. left.", neededEasterbreads, neededEggs, budget)
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement