Advertisement
Spocoman

Cake Tycoon

Oct 3rd, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.76 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var plannedCakes int
  7.     fmt.Scanln(&plannedCakes)
  8.    
  9.     var cakeFlour float64
  10.     fmt.Scanln(&cakeFlour)
  11.  
  12.     var flourAvailable, truffleCount, trufflePrice int
  13.     fmt.Scanln(&flourAvailable)
  14.     fmt.Scanln(&truffleCount)
  15.     fmt.Scanln(&trufflePrice)
  16.    
  17.     cakes := int(float64(flourAvailable) / cakeFlour)
  18.  
  19.     if cakes >= plannedCakes {
  20.         cakePrice := float64(truffleCount * trufflePrice) / float64(plannedCakes) * 1.25
  21.         fmt.Printf("All products available, price of a cake: %.2f", cakePrice)
  22.     } else {
  23.         flourNeeded := float64(plannedCakes) * cakeFlour - float64(flourAvailable)
  24.         fmt.Printf("Can make only %d cakes, need %.2f kg more flour", cakes, flourNeeded)
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement