Advertisement
Spocoman

Sweet Dessert

Oct 13th, 2024
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.67 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.   "fmt"
  5.   "math"
  6. )
  7.  
  8. func main() {
  9.     var budget float64
  10.     fmt.Scanln(&budget)
  11.    
  12.     var guests int
  13.     fmt.Scanln(&guests)
  14.    
  15.     var bananaPrice, eggPrice, berriesKiloPrice float64
  16.     fmt.Scanln(&bananaPrice)
  17.     fmt.Scanln(&eggPrice)
  18.     fmt.Scanln(&berriesKiloPrice)
  19.  
  20.     neededMoney := math.Ceil(float64(guests) / 6) * (bananaPrice * 2 + eggPrice * 4 + berriesKiloPrice / 5)
  21.     if budget >= neededMoney {
  22.         fmt.Printf("Ivancho has enough money - it would cost %.2flv.", neededMoney)
  23.     } else {
  24.         fmt.Printf("Ivancho will have to withdraw money - he will need %.2flv more.", neededMoney - budget)
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement