Advertisement
Spocoman

Club

Sep 16th, 2023
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8.     double neededSum, currentSum, income = 0;
  9.     cin >> neededSum;
  10.     cin.ignore();
  11.  
  12.     string cocktailName;
  13.     getline(cin, cocktailName);
  14.  
  15.     int cocktailCount;
  16.    
  17.     while (cocktailName != "Party!" && income < neededSum) {  
  18.         cin >> cocktailCount;
  19.         cin.ignore();
  20.  
  21.         currentSum = cocktailCount * cocktailName.length();
  22.  
  23.         if ((int)currentSum % 2 == 1) {
  24.             currentSum *= 0.75;
  25.         }
  26.  
  27.         income += currentSum;
  28.  
  29.         getline(cin, cocktailName);
  30.     }
  31.  
  32.     if (neededSum > income) {
  33.         printf("We need %.2f leva more.\n", neededSum - income);
  34.     }
  35.     else {
  36.         cout << "Target acquired.\n";
  37.     }
  38.     printf("Club income - %.2f leva.\n", income);
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement