Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- int bakers, totalSweets = 0;
- cin >> bakers;
- cin.ignore();
- string command;
- double totalSum = 0;
- for (int i = 0; i < bakers; i++) {
- string baker = "";
- int cookies = 0, cakes = 0, waffles = 0;
- while (true) {
- getline(cin, command);
- if (command == "Stop baking!") {
- break;
- }
- if (baker == "") {
- baker = command;
- }
- else {
- string sweet = command;
- int sweetCount;
- cin >> sweetCount;
- cin.ignore();
- if (sweet == "cookies") {
- cookies += sweetCount;
- }
- else if (sweet == "cakes") {
- cakes += sweetCount;
- }
- else {
- waffles += sweetCount;
- }
- totalSweets += sweetCount;
- }
- }
- totalSum += 1.50 * cookies + 7.80 * cakes + 2.30 * waffles;
- printf("%s baked %i cookies, %i cakes and %i waffles.\n", baker.c_str(), cookies, cakes, waffles);
- }
- printf("All bakery sold: %i\nTotal sum for charity: %.2f lv.\n", totalSweets, totalSum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement