Friday, September 1, 2023

The Question "How are you feeling today?" in a Loop

#include <iostream>

#include <string>

using namespace std;

int main() {

    string response;

    bool continueDialog = true;

    int i;

    for(i=1; continueDialog; i++) {

        cout << "Question "<<i <<": How are you feeling today? ";

        cin >> response;

        if (response == "happy") {

            cout << "That's great to hear! Keep spreading the positivity!" << endl;

        } else if (response == "sad") {

            cout << "I'm sorry to hear that. Things will get better!" << endl;

        } else if (response == "angry") {

            cout << "Take a deep breath and try to calm down. It's okay to feel this way sometimes." << endl;

        } else if (response == "excited") {

            cout << "Awesome! What's got you so excited?" << endl;

        } else {

            cout << "I'm not sure how to respond to that mood, but I hope your day gets better!" << endl;

        }

        cout << "Do you want to continue the conversation? (yes/no) ";

        cin >> response;

        if (response != "yes") continueDialog = false;

        if (i==2)  continueDialog = false;   

    }

    if (i==3) cout << "I am tired of you"<< endl;

     else cout << "Goodbye! Have a great day!" << endl;

    return 0;

}


No comments:

Post a Comment

NaCl.xyz Generator with Interactive 3D Visualization

NaCl.xyz Generator with Interactive 3D Visualization NaCl.xyz Generator with Interactive 3D Visualization ...