Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var plannedCakes int
- fmt.Scanln(&plannedCakes)
- var cakeFlour float64
- fmt.Scanln(&cakeFlour)
- var flourAvailable, truffleCount, trufflePrice int
- fmt.Scanln(&flourAvailable)
- fmt.Scanln(&truffleCount)
- fmt.Scanln(&trufflePrice)
- cakes := int(float64(flourAvailable) / cakeFlour)
- if cakes >= plannedCakes {
- cakePrice := float64(truffleCount * trufflePrice) / float64(plannedCakes) * 1.25
- fmt.Printf("All products available, price of a cake: %.2f", cakePrice)
- } else {
- flourNeeded := float64(plannedCakes) * cakeFlour - float64(flourAvailable)
- fmt.Printf("Can make only %d cakes, need %.2f kg more flour", cakes, flourNeeded)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement