Library management system project c++ source code for beginners

INTRODUCTION:

This program is coded in c++  programming language. program has used the concepts of mainly structures, loops, functions and more. It is coded in a way to manage library system where data of books and user are store and manage without file handling.



source code:



 #include<iostream>
using namespace std;


struct bookslibrary {

    string bookname;

    string authorname;

    int id;

    string flag;

    int price;

};


struct userlibrary {

    string username;

    int id;

    int phonenumber;

    string fine;

    string issueS;

};
struct borrowlibrary {

 string username;

 int idb;

 string issue;

 string due;

  string fine;

  string bookname;

  int idu;

  };



bookslibrary b[100];

int cont =0;


userlibrary u[100];

int info =0;


borrowlibrary l[100];

int data=0;


// adding book information

void addbookinfo() {

    cout << "enter book name" << endl;

    cin >> b[cont].bookname;

    cout << "enter author name" << endl;

    cin >> b[cont].authorname;

    cout << "enter id of book" << endl;

    cin >> b[cont].id;

    cout << "enter price:" << endl;

    cin >> b[cont].price;

    cout << "is book issued (yes/no)" << endl;

    cin >> b[cont].flag;

 cont++;

 }


// add user information


void adduserinfo() {

    cout << "enter username" << endl;

    cin >> u[info].username;

    cout << "enter user id" << endl;

    cin >> u[info].id;

    cout << "enter phone number" << endl;

    cin >> u[info].phonenumber;

    cout << "fine (yes/no)" << endl;

    cin >> u[info].fine;

    cout << "book issue (yes/no)" << endl;

    cin >> u[info].issueS;

 info++;

 }


// add borrowing information


void addborrowcriteria() {

    cout << "enter book name" << endl;

    cin >> l[data].bookname;

    cout << "enter book id" << endl;

    cin >> l[data].idb;

    cout << "enter user id" << endl;

    cin >> l[data].idu;

    cout << "enter user name" << endl;

    cin >> l[data].username;

    cout << "enter issue date" << endl;

    cin >> l[data].issue;

    cout << "enter due date " << endl;

    cin>>l[data].due;

    cout << "fine(yes/no)" << endl;

    cin >> l[data].fine;

    data++;

}


// display book information


void displaybookinfo() {

    cout << "====================" << endl;

    cout << " 'book information'" << endl;

    cout << "====================" << endl;

    for (int i = 0; i < cont; i++) {

        cout << "\n book name:" << b[i].bookname << endl;

        cout << "\n author name: " << b[i].authorname << endl;

        cout << "\n id no: " << b[i].id << endl;

        cout << "\n issue status: " << b[i].flag << endl;

        cout << "\n price: " << b[i].price << endl;

        cout << "••••••••••••••••••••••" << endl;

    }


}


// display user information

void displayuserinformation() {

    cout << "======================" << endl;

    cout << "  'user information'" << endl;

    cout << "======================" << endl;

    for (int i = 0; i < info; i++) {

        cout << "\n user name: " << u[i].username << endl;

        cout << "\n user id: " << u[i].id << endl;

        cout << "\n phone no: " << u[i].phonenumber << endl;

        cout << "\n fine (yes/no): " << u[i].fine << endl;

        cout << "\n book issue: " << u[i].issueS << endl;

        cout << "••••••••••••••••••••••" << endl;

    }


}


// display borrow criteria


void displayborrowcriteria() {

    cout << "====================" << endl;

    cout << "  'borrow status' " << endl;

    cout << "====================" << endl;

    for (int i = 0; i < cont && i < info; i++) {

        cout << "\n book name: " << l[i].bookname << endl;

        cout << "\n book id: " << l[i].idb << endl;

        cout << "\n user id: " << l[i].idu << endl;

         cout << "\n user name: " << l[i].username << endl;

         cout << "\n issue date: " <<l[i].issue<<endl;

        cout << "\n due date: " <<l[i].due << endl;

        cout << "\n fine: " << l[i].fine << endl;

        cout << "••••••••••••••••••••••" << endl;

    }




}


// search by name book info


void searchbookinfo() {

    int s;

    cout << "enter book id  to be searched" << endl;

    cin >> s;

    cout << "===================" << endl;

    cout << "book information" << endl;

    cout << "===================" << endl;

    for (int i = 0; i < cont; i++) {

        if (b[i].id == s) {

            cout << "\n book name: " << b[i].bookname << endl;

            cout << "\n author name: " << b[i].authorname << endl;

            cout << "\n id no: " << b[i].id << endl;

            cout << "\n issue status: " << b[i].flag << endl;

            cout << "\n price: " << b[i].price << endl;

    }

}

        }

// search user info by id


void searchuserid() {

    int d;

    cout << "enter user id to be searched" << endl;

    cin >> d;

    cout << "===================" << endl;

    cout << "user information" << endl;

    cout << "===================" << endl;

    for (int i = 0; i < info; i++) {

        if (u[i].id == d) {

            cout << "\n user name: " << u[i].username << endl;

            cout << "\n user id: " << u[i].id << endl;

            cout << "\n phone no: " << u[i].phonenumber << endl;

            cout << "\n fine (yes/no): " << u[i].fine << endl;

            cout << " \n book issue: " << u[i].issueS << endl;


        }

    }


}


// list of all books


void listbooks() {

    cout << "====================" << endl;

    cout << "  'list of books' " << endl;

    cout << "===================" << endl;

    for (int i = 0; i < cont; i++) {

        cout << i+1<< b[i].bookname << endl;

    }

    cout << "====================" << endl;

}


//list of users

void listusers() {

    cout << "===================" << endl;

    cout << "  'list of users' " << endl;

    cout << "===================" << endl;

    for (int i = 0; i < info; i++) {

        cout << i+1<< u[i].username << endl;

    }

    cout << "====================" << endl;

}


//books of specific author


void bookauthor() {

    string author;

    cout << "enter author for its book list" << endl;

    cin >> author;

    cout << "====================" << endl;

    cout << "books of " <<author<<":"<<endl;

    cout << "===================" << endl;

    for (int i = 0; i < cont; i++){

    if(b[i].authorname==author)

    {

    cout << b[i].bookname << endl;

    }

    }

    cout << "===================" << endl;

    }


//list of users with fine


void fine() {

cout << "========================" << endl;

cout << "list of users with fine" << endl;

cout << "========================" << endl;

for(int i=0;i<info;i++)

{

if(u[i].fine=="yes")

{

cout<<"ID "<<"name"<<endl;

cout <<i+1<<"." << u[i].username << endl;

}

}

cout << "===================" << endl;

}

int main() {

string password;

cout << "enter password" << endl;

cin>>password;

if(password=="UMT")

system("color 70");

{

    cout << "°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°" << endl;

    cout << "  LIBRARY MANAGEMENT SYSTEM" << endl;

    cout << "°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°" << endl;

    while (1) {

        cout << "1. for add book information.          " << endl;

        cout << "2. for add user information.           " << endl;

        cout << "3. for add book criteria.             " << endl;

        cout << "4. for display book information.      " << endl;

        cout << "5. for display user information.       " << endl;

        cout << "6. for display borrow criteria/status. " << endl;

        cout << "7. search book information by id.    " << endl;

        cout << "8. search user information by id.      "<<endl;

        cout << "9. list of all books.                  " << endl;

        cout << "10. list of users.                      " << endl;

        cout << "11. books of specific author.          " << endl;

        cout << "12. list of users with fine pending.   " << endl;

        cout << "13. exit.                              "<<endl;

        cout << "======================================" << endl;


    int a;

    cout << "enter your choice" << endl;

    cin >> a;

    switch (a)

    {

    case 1:

    addbookinfo();

    break;

    case 2:

    adduserinfo();

    break;

    case 3:

    addborrowcriteria();

    break;

    case 4:

    displaybookinfo();

    break;

    case 5:

    displayuserinformation();

    break;

    case 6:

    displayborrowcriteria();

    break;

    case 7:

    searchbookinfo();

    break;

    case 8:

    searchuserid();

    break;

    case 9:

    listbooks();

    break;

    case 10:

    listusers();

    break;

    case 11:

    bookauthor();

    break;

    case 12:

    fine();

    break;

    case 13:

    exit(0);

    break;

    default:

    cout << "you have entered invalid number " << endl;

    break;

    }

    }

    }

    return 0;


}

*This is how it will appear menu after entering password.





Comments

Popular posts from this blog

How to hack Facebook account using termux (password guessing method)

From Start To Success| A Step By Step Guide To Becoming A Profitable Amazon Seller

Bitcoin Price Prediction In 2024: Boom Or Bust?