Advertisement
Spocoman

Cake Tycoon

Oct 11th, 2023
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int plannedCakes;
  7.     cin >> plannedCakes;
  8.  
  9.     double cakeFlour;
  10.     cin >> cakeFlour;
  11.  
  12.     int flourAvailable, truffleCount, trufflePrice;
  13.     cin >> flourAvailable >> truffleCount >> trufflePrice;
  14.  
  15.     int cakes = (int)(flourAvailable / cakeFlour);
  16.  
  17.     if (cakes >= plannedCakes) {
  18.         double cakePrice = (double)truffleCount * trufflePrice / plannedCakes * 1.25;
  19.         printf("All products available, price of a cake: %.2f", cakePrice);
  20.     }
  21.     else {
  22.         double flourNeeded = plannedCakes * cakeFlour - flourAvailable;
  23.         printf("Can make only %i cakes, need %.2f kg more flour", cakes, flourNeeded);
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement