Advertisement
Spocoman

Easter Guests

Sep 17th, 2023
812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     double guests, budget;
  9.     cin >> guests >> budget;
  10.  
  11.     budget -= ceil(guests / 3) * 4 + guests * 2 * 0.45;
  12.  
  13.     if (budget < 0) {
  14.         cout << "Lyubo doesn't have enough money.\n"
  15.             << "He needs " << fixed << setprecision(2) << abs(budget) << " lv. more.\n";
  16.     }
  17.     else {
  18.         cout << "Lyubo bought " << ceil(guests / 3) << " Easter bread and " << guests * 2 << " eggs.\n"
  19.             << "He has " << fixed << setprecision(2) << budget << " lv. left.\n";
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement