Monday, April 5, 2021

Password in C++

A simple password program that I wrote in the C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com





Program Listing

password.cpp


// password.cpp

// Prof. Jake R. Pomperada, MAED-IT,MIT

// www.jakerpomperada.com / www.jakerpomperada.blogspot.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental Philippines


#include <iostream>

#include <string>


using namespace std;


int main()

{


    string password = "123";

    string passwordEntry;

    int attempts = 0;


    cout <<"\n\n" ;

    cout << "\tPassword in C++\n\n";

    cout << "\tPlease enter your password: ";

    getline(cin, passwordEntry, '\n');


    while ( passwordEntry != password && attempts <=2 )

    {

        cout << "\n";

        cout <<"\tPassword Attempt No. : " <<attempts+1;

        cout << "\n";

        cout << "\tEnter Password Again : ";

        getline(cin, passwordEntry, '\n');

        attempts++;

    }


    if ( passwordEntry == password && attempts <=3 )

    {

        cout << "\n";

        cout << "\tAccess Granted in the System.";

    }

    else

    {

        cout << "\n";

        cout << "\tSorry, you are only allowed 3 password login attempts.";

        cout << "\n\n";

    }


}



No comments:

Post a Comment