Solved: Code Coach: Jungle Camping. I am stuck. The last result is wrong. Helpful for any advice.
#include <iostream> #include <vector> using namespace std; int main() { string animal1; string animal2; string animal3; string animal4; string animal5; cin >> animal1 >> animal2 >> animal3 >> animal4 >> animal5; vector<string> sounds{animal1, animal2, animal3, animal4, animal5}; vector<string> animals; int soundsTotal = sounds.size(); while (soundsTotal > 0) { for (const string &sound : sounds) { if (sound == "Rawr") { animals.push_back("Tiger"); } else if (sound == "Chirp") { animals.push_back("Bird"); }else if (sound == "Ssss"){ animals.push_back("Snake"); }else if (sound == "Grr"){ animals.push_back("Lion"); } soundsTotal--; // Decrement soundsTotal within the loop } } for (string animal : animals) { cout << animal << " "; } return 0; }