Library Management System in Java (Source Code)

This is a Library management system consist of data of the registered students and the staff of library as well as the Collection of books. Each student have its own unique id and password used to issue the book to the desired amount of time. There are many collections in this code like Electrical Engineering,Bio Sciences and Computer Sciences related books.Only registered user can access the management system and access the books . In code there is also a brief introduction about the Library.

Note: Only use the username and password as given in the code or you can change it by your self.Run this code on Eclipse.

Please do comment if you have any query or issue .Thanks and enjoy..!!!

Source Code:

//LIBRARY MANAGEMENT SYSTEM (PROJECT OF JAVA)

import java.util.*;

public class Zain {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true){

String a = “ZainMalik”;
String b = “ciit083”;
System.out.println(“Enter your Library username”);
String username = input.next();
System.out.println(“Enter your Library password”);
String pasword = input.next();
if (username.equals(a) && pasword.equals(b)) {
System.out.println(“Welcome Zain Malik to the Comsats Library”);
break;
} else
System.out.println(“you have entered wrong password or email”);

}
mainMenu();{
int n = input.nextInt();
while (true){
try{
switch (n) {
case 1:
collections();
break;
case 2:
Books();
break;
case 3:
AboutUs();
break;
case 4:
Timings();
break;
case 5 :
booksInaFloor();
break;

case 0:
break;

default:
System.out.println(“You have entred the wrong choice”);
break;
}
} catch (InputMismatchException e) {
System.out.println(“Enter digit only”);
}
input.nextLine();
if (n == 0) {
System.out.println(“You are loggedout “);
break;

}
}
}

}

static void mainMenu(){
try{
Scanner input = new Scanner(System.in);

System.out.println(” press 1 for our collection” + “\n press 2 to check Books ”
+ “\n press 3 to check detail about us” + “\n press 4 for our timings”

+ “\n press 5 to check number of books in a floor” + “\n press 0 to logout “);
}

catch (InputMismatchException e) {
System.out.println(“Enter digit only”);}}

static void collections() {
Scanner in = new Scanner(System.in);
System.out.println(
” Enter the name of collection:\n1) Bio Sciences\n2) Computer Science\n3) Electrical Engineering\n”);
int collection = in.nextInt();
String collection1 = “Bio Sciences”;
if (collection == 1) {
System.out.println(“We have the following books in this collection” + “\n Social and Behavioural Sciences”
+ “\n Physical Sciences ” + “\n Health and Life Sciences”
+ “\n Elsevier Masson French Health Sciences Collection”
+ “\n Portuguese Business, Science and Technology Collection”
+ “\n Spanish Language eBooks Collection” + “\n German Medical eBooks Collection”);
}
String collection2 = “Computer Science”;
if (collection == 2) {
System.out.println(“We hava such types of books in this collection”
+ “\n Introduction to computer and programming” + “\n Obect oriented programmming”
+ “\n Discreate Structure” + “\n Multi Programming” + “\n Web bulding” + “Html books “);
}
String collection3 = “Electrical Engineering”;
if (collection == 3) {
System.out.println(“We have such types of books in this collection”
+ “\n Simon Haykin, Digital Communication Systems, Wiley, 2013.”
+ “\n Bernard Sklar, Digital Communications: Fundamental”
+ “\n John G. Proakis, Masoud Sal, 3rd Edition, CL Engineering, 2012.”
+ “\n Anant Agarwal, and Jeffrey Lang, Foundations of Analog and Digital Electronic Circuits,”
+ “\n Richard C. Dorf, and James A. Svoboda, Introduction to Electric Circuits”
+ “\n Electric Circuit Analysis”);
}
System.out.println(“Press 0 to return to main menu”);
while (true) {
int choice = in.nextInt();
if (choice == 0)
mainMenu();
System.exit(0);
}
}

static void AboutUs() {
Scanner in = new Scanner(System.in);
System.out
.println(“Select an desire option from below” + “\n press 1 to check when this library was established”
+ “\n press 2 to check detail about the staff ” + “\n press 3 to check our goals”
+ “\n press 4 to check our rules regarding book issues and others”);
int choice = in.nextInt();
if (choice == 1) {
System.out.println(“This library was established in 1998”);
}
if (choice == 2) {
System.out.println(“We have 50 staff members which include 20 female and 30 men”);
}
if (choice == 3) {
System.out.println(“Our goals are to educate people” + “\n take them to a high level”);
}
if (choice == 4) {
System.out.println(“We have the following rules” + “\n 1. You must be a student of CIIT ISlamabad”
+ “\n 2. Please mantain silence” + “\n 3. Enterance is not allowed without ID Card”
+ “\n 4. For the issuance of a book, you must have the library card”);
}else{
System.out.println(“Press 0 to return to main menu”);}
while (true) {
choice = in.nextInt();
if (choice == 0)
mainMenu();
System.exit(0);
}
}

static void Timings() {
System.out.println(“Library timings are from (9:00 am to 9:00 pm throughout the week ”
+ “\nLibraray is Closed on Sunday “);
}

static void Books() {
System.out.println(“Natural Sciences \n 1-Biology by Ateeq \n 2-Zoology by Jonathan Marks ”
+ “\n Engineering \n 3-Civil Engineering by AR Rehmans \n 4-Electric circuits by Sadiku ”
+ “\n Biology \n 5-A comprehensive study of botanical animals \n 6-Zoology by Ahmed Quaidian ”
+ “\n Literature \n 7-SAT by JK Rowling \n 8-Oxford Basic Grammar ”
+ “\n Computer Science \n 9-Intro to Java by Y.Daniel Liang \n 10-C++ by Naveed ur Rahman”
+ “\n Human Anatomy \n 11-Comprehensive anatomy by B.D Churasia \n 12-Muscular System by Dr Omar”
+ “\n Calculus \n 13-Calculus by Howard Anton \n 14-A Guide to Calculus”);
Scanner input = new Scanner(System.in);

System.out.println(“Enter your choice”);
int Books = input.nextInt();
switch (Books) {
case 1:
System.out.println(” You have issued biology by ateeq”);
break;
case 2:
System.out.println(“You have issued Zoology by Jonathan Marks”);
break;
case 3:
System.out.println(“You have issued Civil Engineering by AR Rehmans”);
break;
case 4:
System.out.println(“You have issued Circuits by Sadiku”);
break;
case 5:
System.out.println(“You have issued A comprehensive study of botanical animals”);
break;
case 6:
System.out.println(“You have issued Zoology by Ahmed “);
break;
case 7:
System.out.println(“You have issued English SAT by JK Rowling”);
break;
case 8:
System.out.println(“You have issued Oxford Basic Grammar”);
break;
case 9:
System.out.println(“You have issued Intro to Java by Y.Daniel Liang”);
break;
case 10:
System.out.println(“You have issued C++ by Naveed ur Rahman”);
break;
case 11:
System.out.println(“You have issued Comprehensive anatomy by B.D Churasia”);
break;
case 12:
System.out.println(“You have issued Muscular System by Dr Omar”);
break;
case 13:
System.out.println(“You have issued Calculus by Howard Anton”);
break;
case 14:
System.out.println(“You have issued Guide to calculus”);

break;
default:
System.out.println(“You have etered the wrong number”);
break;

}

} static void booksInaFloor(){
Scanner in =new Scanner(System.in);
System.out.println(“We have total 2 floors”
+”\n Press the number of floor to check the books in that floor”
+”\n ***************************************”);
System.out.println(“Enter the number of floor”);
int floornumber=in.nextInt();
if(floornumber==1){
int floor1[]=new int[14];
System.out.println(“We have now ” + floor1.length + “books”);

}
if(floornumber==2){
int floor2[]=new int[18];
System.out.println(“we have now ” + floor2.length + ” books”);
}

System.out.println(“Press 0 to return to main menu”);
while(true){
try{
int choice=in.nextInt();
if(choice==0){
mainMenu();
System.exit(0);
}
break;
}
catch(InputMismatchException e){
System.out.println(“Invalid entry”);
}

}}}

Add a Comment

Your email address will not be published. Required fields are marked *