Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int availableEggs, eggs, soldEggs = 0;
- cin >> availableEggs;
- string input;
- cin >> input;
- while (input != "Close") {
- cin >> eggs;
- if (input == "Buy") {
- if (availableEggs - eggs < 0) {
- break;
- }
- availableEggs -= eggs;
- soldEggs += eggs;
- }
- else if (input == "Fill") {
- availableEggs += eggs;
- }
- cin >> input;
- }
- if (input == "Close") {
- cout << "Store is closed!\n"
- << soldEggs << " eggs sold.\n";
- }
- else {
- cout << "Not enough eggs in store!\n"
- << "You can buy only " << availableEggs << ".\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement