Speed up development with full-stack environments for every branch.

Learn More

temperary auth [C++]

Forked from Hello World C++ Example.

3 Runs 10 Views 1 Copies
Saved

Saved

PotatoChips 1

PotatoChips
published 18 days ago

    #include <iostream>
    using namespace std;
    
    int main ()
    {
        string userName;
        string userPassword;
        int loginAttempt = 0;
    
        while (loginAttempt < 5)
        {
            cout << "Please enter your user name: ";
            cin >> userName;
            cout << "Please enter your user password: ";
            cin >> userPassword;
    
            if (userName == "User1" && userPassword == "Password")
            {
                cout << "Welcome User 1!\n";
                break;
            }
            if (userName == "User2" && userPassword == "Password")
            {
                cout << "Welcome User 2!\n";
                break;
            }
            else if (userName == "User3" && userPassword == "Password")
            {
                cout << "Welcome User 3!\n";
                break;
            }
            else
            {
                cout << "Invalid login attempt. Please try again.\n" << '\n';
                loginAttempt++;
            }
        }
        if (loginAttempt == 5)
        {
                cout << "Too many login attempts! The program will now terminate.";
                return 0;
        }
        
        {
        cout << "Authorized Menu will now launch.";
        }
        //insert mod menu here
    }
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).