Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<cmath>
- using namespace std;
- int main()
- {
- int playersNumber;
- cin >> playersNumber;
- string bakerName;
- string foodType;
- int currentFoodTypeColBaked;
- double totalSumForCharity = 0;
- int totalBakerySold = 0;
- for (int player=1; player <= playersNumber; player++)
- {
- int cookieCounter = 0;
- int cakesCounter = 0;
- int wafflesCounter = 0;
- cin>>bakerName;
- cin.ignore();
- getline(cin, foodType);
- cin >> currentFoodTypeColBaked;
- while (foodType != "Stop baking!")
- {
- if (foodType == "cookies")
- {
- cookieCounter += currentFoodTypeColBaked;
- totalSumForCharity += cookieCounter * 1.50;
- totalBakerySold += cookieCounter;
- }
- else if (foodType == "cakes")
- {
- cakesCounter += currentFoodTypeColBaked;
- totalSumForCharity += cakesCounter * 7.80;
- totalBakerySold += cakesCounter;
- }
- else if (foodType == "waffles")
- {
- wafflesCounter += currentFoodTypeColBaked;
- totalSumForCharity += wafflesCounter * 2.30;
- totalBakerySold += wafflesCounter;
- }
- cin.ignore();
- getline(cin, foodType);
- if (foodType == "Stop baking!")
- {
- break;
- }
- cin >> currentFoodTypeColBaked;
- }
- cout << bakerName << " baked " << cookieCounter << " cookies, " << cakesCounter << " cakes and " << wafflesCounter << " waffles." << endl;
- }
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << "All bakery sold: " << totalBakerySold << endl;
- cout << "Total sum for charity: " << totalSumForCharity << " lv." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement