Hello, I just wanted to help with my code
here's my questions

  1. How can I input "computer" in any in any order and case insensitively and still get the correct output?

Here are the replacement

COMPUTERS.X
1234567890.X
  1. If I input other letters that is not included in the COMPUTERS.X the program will terminate and ask again if i should input again.

example:

Input Code: Most.x
UNABLE TO CONVERT YOUR INPUT
INPUT AGAIN? Type YES to input again, type NO to end program:
  1. Is there any way or method to replace the whole string array instead of
    replace(CODES.begin(),CODES.end(),'C','1');

here's my code

    #include <iostream>
    #include <string.h>
    #include <algorithm>

    using namespace std;

    int main()
    {
        string CODES;
        char choice[5];

        do
        {
            cout << "Input code:  ";
            cin >> CODES;

        replace(CODES.begin(),CODES.end(),'C','1');
            replace(CODES.begin(),CODES.end(),'O','2');
            replace(CODES.begin(),CODES.end(),'M','3');
            replace(CODES.begin(),CODES.end(),'P','4');
            replace(CODES.begin(),CODES.end(),'U','5');
            replace(CODES.begin(),CODES.end(),'T','6');
            replace(CODES.begin(),CODES.end(),'E','7');
            replace(CODES.begin(),CODES.end(),'R','8');
            replace(CODES.begin(),CODES.end(),'S','9');
            replace(CODES.begin(),CODES.end(),'X','0');
            replace(CODES.begin(),CODES.end(),'c','1');
            replace(CODES.begin(),CODES.end(),'o','2');
            replace(CODES.begin(),CODES.end(),'m','3');
            replace(CODES.begin(),CODES.end(),'p','4');
            replace(CODES.begin(),CODES.end(),'u','5');
            replace(CODES.begin(),CODES.end(),'t','6');
            replace(CODES.begin(),CODES.end(),'e','7');
            replace(CODES.begin(),CODES.end(),'r','8');
            replace(CODES.begin(),CODES.end(),'s','9');
            replace(CODES.begin(),CODES.end(),'x','0');

            cout << "Value: " << CODES << endl;

            cout << "Do you want to enter another code? (Y/N) ";
            cin >> choice;
        }
        while(strcmpi(choice, 'yes') == 0 ||strcmpi(choice, 'y') == 0 );
        {
            if (strcmpi(choice, 'no') == 0 || strcpmi(choice, 'no' == 0);
            {
            cout << "Program terminate";
            }
        }

        return 0;
    }

any help will be appreciated, thank you very much
ps. i prefer classic c++

hes8 commented: I'm wondering what you mean by - "computer" in any in any order - do you mean that retmpuco would still give "computer" as an output? +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.