Advertisement
Spocoman

Juice Diet

Oct 10th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.81 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var r, s, c, maxJuice, raspberries, strawberries, cherries int
  7.     fmt.Scanln(&r)
  8.     fmt.Scanln(&s)
  9.     fmt.Scanln(&c)
  10.     fmt.Scanln(&maxJuice)
  11.  
  12.     juice := 0.0
  13.  
  14.     for j := 0; j <= r; j++ {
  15.         for k := 0; k <= s; k++ {
  16.             for l := 0; l <= c; l++ {
  17.                 currentJuice := 4.5 * float64(j) + 7.5 * float64(k) + 15 * float64(l)
  18.                 if juice < currentJuice && currentJuice <= float64(maxJuice) {
  19.                     juice = currentJuice
  20.                     raspberries = j
  21.                     strawberries = k
  22.                     cherries = l
  23.                 }
  24.             }
  25.         }
  26.     }
  27.  
  28.     fmt.Printf("%d Raspberries, %d Strawberries, %d Cherries. Juice: %d ml.", raspberries, strawberries, cherries, int(juice))
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement