Advertisement
Spocoman

Easter Decoration

Sep 17th, 2023
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int clients;
  8.     cin >> clients;
  9.     cin.ignore();
  10.  
  11.     string stock;
  12.  
  13.     double totalSum = 0;
  14.  
  15.     for (int i = 0; i < clients; i++) {
  16.         getline(cin, stock);
  17.  
  18.         int counter = 0;
  19.         double sum = 0;
  20.  
  21.         while (stock != "Finish") {
  22.  
  23.             if (stock == "basket") {
  24.                 sum += 1.50;
  25.             }
  26.             else if (stock == "wreath") {
  27.                 sum += 3.80;
  28.             }
  29.             else if (stock == "chocolate bunny") {
  30.                 sum += 7.00;
  31.             }
  32.  
  33.             getline(cin, stock);
  34.             counter++;
  35.         }
  36.  
  37.         if (counter % 2 == 0) {
  38.             sum *= 0.80;
  39.         }
  40.  
  41.         totalSum += sum;
  42.         printf("You purchased %i items for %.2f leva.\n", counter, sum);
  43.     }
  44.     printf("Average bill per client is: %.2f leva.\n", totalSum / clients);
  45.  
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement