Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     int playersNumber;
  8.  
  9.     cin >> playersNumber;
  10.  
  11.     string bakerName;
  12.    
  13.  
  14.     string foodType;
  15.     int currentFoodTypeColBaked;
  16.    
  17.  
  18.    
  19.     double totalSumForCharity = 0;
  20.     int totalBakerySold = 0;
  21.     for (int player=1; player <= playersNumber; player++)
  22.     {
  23.         int cookieCounter = 0;
  24.         int cakesCounter = 0;
  25.         int wafflesCounter = 0;
  26.    
  27.         cin>>bakerName;
  28.         cin.ignore();
  29.         getline(cin, foodType);
  30.         cin >> currentFoodTypeColBaked;
  31.  
  32.         while (foodType != "Stop baking!")
  33.         {
  34.  
  35.             if (foodType == "cookies")
  36.             {
  37.                 cookieCounter += currentFoodTypeColBaked;
  38.                 totalSumForCharity += cookieCounter * 1.50;
  39.                 totalBakerySold += cookieCounter;
  40.             }
  41.             else if (foodType == "cakes")
  42.             {
  43.                 cakesCounter += currentFoodTypeColBaked;
  44.                 totalSumForCharity += cakesCounter * 7.80;
  45.                 totalBakerySold += cakesCounter;
  46.             }
  47.             else if (foodType == "waffles")
  48.             {
  49.                 wafflesCounter += currentFoodTypeColBaked;
  50.                 totalSumForCharity += wafflesCounter * 2.30;
  51.                 totalBakerySold += wafflesCounter;
  52.             }
  53.             cin.ignore();
  54.             getline(cin, foodType);
  55.  
  56.             if (foodType == "Stop baking!")
  57.             {
  58.                 break;
  59.             }
  60.             cin >> currentFoodTypeColBaked;
  61.         }
  62.  
  63.         cout << bakerName << " baked " << cookieCounter << " cookies, " << cakesCounter << " cakes and " << wafflesCounter << " waffles." << endl;
  64.        
  65.     }
  66.     cout.setf(ios::fixed);
  67.     cout.precision(2);
  68.     cout << "All bakery sold: " << totalBakerySold << endl;
  69.     cout << "Total sum for charity: " << totalSumForCharity << " lv." << endl;
  70.    
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement