59.9k views
1 vote
Read string integer value pairs from input until "End" is read. For each string read, if the following integer read is less than 45, output the string followed by ": reorder soon". End each output with a newline.

Ex: If the input is Chest 49 Organizer 2 Couch 3 End, then the output is:

Organizer: reorder soon
Couch: reorder soon

1 Answer

1 vote

Answer:

#include <iostream>

#include <string>

using namespace std;

int main() {

string s;

int n;

while (cin >> s) {

if (s == "End") break;

cin >> n;

if (n < 45) cout << s << ": reorder soon" << endl;

}

return 0;

}

Step-by-step explanation:

User Ben Krueger
by
8.5k points