Professional Documents
Culture Documents
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<windows.h>
struct Book {
char author[40];
char title[40];
int isbn;
char subject[40];
char loan[40];
int shelf;
char loan_status[40];
int no_copies;
char mark[40];
};
struct User {
char name[40];
int id;
int max;
int current;
int allocated[100];
char date_start[100][40];
char date_end[100][40];
int charges;
int account_status;
};
/////////////////////////
int user_section(struct User *, struct Book *, int, int);
ch = getch();
switch (ch) {
case 'A':
case 'a':
system("cls");
printf("---------------------\n");
printf(" Add New Book\n");
printf("---------------------\n");
b = add_book(book, b);
break;
case 'D':
case 'd':
display_book(book, 0, b);
break;
case 's':
case 'S':
printf(" Search Book");
printf("\n-------------------------------\n");
search_book(book, b);
break;
case 'U':
case 'u':
printf(" Update Book");
printf("\n-------------------------------\n");
update_book(book, b);
break;
case 'm':
break;
case 'M':
break;
case 'e':
case 'E':
exit(0);
break;
default:
printf("\n-- Note : Invalid Choice --\n");
break;
}
printf("\n-------------------------\n");
printf("Press Any Key To Continue");
printf("\n-------------------------\n");
getch();
} while (ch != 'm' && ch != 'M');
return b;
}
b++;
return b;
}
printf("--------------------------------------------------------------------------------------
----------------------\n");
for (; n < z; n++) {
printf("%12s", b[n].author);
printf(" |%12s", b[n].title);
printf(" |%6d", b[n].isbn);
printf(" |%7d", b[n].shelf);
printf(" |%10s", b[n].subject);
printf(" |%12s", b[n].loan);
printf(" |%15s", b[n].loan_status);
printf(" |%8d", b[n].no_copies);
printf(" |%10s\n", b[n].mark);
}
printf("\n--------------------------\n");
printf(" Update Book");
printf("\n--------------------------");
printf("\n Press A To Add Mark");
printf("\n Press U To Update Details");
printf("\n Press M To Go Back");
printf("\n--------------------------\n");
ch = getch();
if (ch == 'a' || ch == 'A') {
printf("Enter Mark to Book: ");
scanf("%s", book[i].mark);
printf("\n-- Mark Added Successfully --");
} else if (ch == 'u' || ch == 'U') {
printf("\n Enter Updated Data");
printf("\n--------------------------\n");
add_book(book, i);
printf("\n-- Data Updated Successfully --");
} else if (ch == 'm' || ch == 'M') {
return;
} else {
printf("Invalid Choice\n");
}
}
}
////
////
ch = getch();
switch (ch) {
case 'A':
case 'a':
system("cls");
printf("---------------------\n");
printf(" Add New User\n");
printf("---------------------\n");
u = add_user(user, u);
break;
case 'B':
case 'b':
allocate_book(user, book, u, b);
break;
case 'R':
case 'r':
return_book(user, book, u, b);
break;
case 'D':
case 'd':
system("cls");
display_user(user, 0, u);
break;
case 's':
case 'S':
printf(" Search User");
printf("\n-------------------------------\n");
int i = search_user(user, u);
display_user_book(user, book, i, b);
break;
case 'U':
case 'u':
printf(" Search User To Update Privilege");
printf("\n-------------------------------\n");
int z = search_user(user, u);
printf("\nEnter Updated Max Number of Books");
scanf("%d", &user[z].max);
printf("\n-- Data Updated Successfully --\n");
break;
case 'p':
case 'P':
account_block(user, u);
break;
case 'm':
case 'M':
break;
case 'e':
case 'E':
exit(0);
break;
default:
printf("\n-- Note : Invalid Choice --\n");
break;
}
printf("\n-------------------------\n");
printf("Press Any Key To Continue");
printf("\n-------------------------\n");
getch();
} while (ch != 'm' && ch != 'M');
return u;
}
user[u].account_status = 1;
user[u].current = 0;
user[u].charges = 0;
u++;
return u;
}
printf("\n------------------------------------------------------------------------------------
-----------\n");
for (; n < z; n++) {
printf("%15s", b[n].name);
printf(" |%10d", b[n].id);
printf(" |%15d", b[n].max);
printf(" |%15d", b[n].current);
printf(" |%15d", b[n].charges);
if (b[n].account_status == -1) {
printf(" | Blocked\n");
} else {
printf(" | Active\n");
}
printf("\n____________________________________________________________________________________
_________________________\n");
int i;
printf("\nSr. # | Author | Title | ISBN | Shelf | Subject | Issue
Date | Due Date\n");
printf("--------------------------------------------------------------------------------------
----------------------\n");
for (i = 0; i < user[u].current; i++) {
int n = user[u].allocated[i];
printf("%5d", i + 1);
printf(" |%12s", book[n].author);
printf(" |%12s", book[n].title);
printf(" |%6d", book[n].isbn);
printf(" |%7d", book[n].shelf);
printf(" |%10s", book[n].subject);
printf(" |%15s", user[u].date_start[i]);
printf(" |%15s\n", user[u].date_end[i]);
}
}
}
}
void library_statistics(struct Book *book, struct User *user, int b, int u){
system("cls");
printf("\n-------------------------------\n");
printf(" Library Statistics");
printf("\n-------------------------------\n\n");
display_book(book,0,b);
printf("\n____________________________________________________________________________________
____________\n");
display_user(user,0,u);
printf("\n-------------------------\n");
printf("Press Any Key To Continue");
printf("\n-------------------------\n");
getch();
}
int main() {
struct Book book[100];
struct User user[100];
int b = 0, u = 0;
char ch;
do {
system("cls");
printf("\n-------------------------------\n");
printf(" Library Management System");
printf("\n-------------------------------\n");
printf("Press\n");
printf("B For Book Section\n");
printf("U For User Section\n");
printf("L For Library Section\n");
printf("E To Exit\n");
printf("-------------------------------\n");
ch = getch();
switch (ch) {
case 'b':
case 'B':
b = book_section(book, b);
break;
case 'U':
case 'u':
u = user_section(user, book, u, b);
break;
case 'L':
case 'l':
library_statistics(book, user, b, u);
break;
case 'e':
case 'E':
exit(0);
default:
printf("\n-- Note : Invalid Choice --\n");
printf("\n-------------------------\n");
printf("Press Any Key To Continue");
printf("\n-------------------------\n");
getch();
break;
}
} while (1);
}
Part 2:
1. Problem Specification:
Here the problem specification is to digitalize the current manual system of
university library where user can manage thing digitally and efficiency of working can
be increased.
2. Analysis:
a. Input:
In this system inputs will be:
i. Book details for adding new book.
ii. Updated details for present book.
iii. Book status.
iv. Details for new user.
v. Book name for searching.
b. Output:
Output will be complete Library Management System having different functions:
i. In case of search the output will be details of specified book.
ii. In case or statistics, the output will be the complete statistics of.
iii. Book Status
c. Requirement:
i. It must be able to store the set of books including their author(s), title,
ISBN, subject, loan type (normal, short loan, no-take-out), shelf mark,
loan status, number of copies, etc. Also, it should provide options for
altering the details of a book, mark it as lost/damaged/ordered, etc.
ii. Registration of a new library user with varying privileges (e.g., maximum
number of books), which can be altered for any existing user at any time.
iii. Search for a particular book and allocate a book to a specific borrower for
a specific period. Also, implement returns and renewals.
iv. Provide library statistics about the number of books and borrowers and if
possible, their different types.
v. Provide borrower statistics about the number of books and charges
incurred to a particular account. Implement payment and account
blocking.
3. Design:
Following steps are required to solve the problem.
Adding Record:
1. Allow user to enter choice to perform a specific function.
2. Get input from the user to add new book.
3. Store the input in a list of already present books.
4. Add new user.
5. Set privilege for a user.
Search, Display and Updating Record:
6. Display the list of stores books.
7. Get name of the book to search it.
8. Display searched book.
9. Get updated details to update any searched book.
10. Display list of users.
11. Search for user.
Book Allotment:
10. Search for book to allot.
11. Allot a book to a user for a specific time.
12. Set option for return and renewal.
13. Manage Payment
Library Statistics:
13. Display library statistics.
14. Provide borrower statics.
4. Implementation:
1. main () It controls the flow of program. (Step 1)
2. book_section() It controls the flow of book section.
3. user_sectio() It controls the flow of user section.
4. add_book () Used to add new book. (Step 2-3)
5. add_user() Used to add new user. (Step 4-5)
6. display_book () Used to display the list of all books. (Step 6)
7. search_book() Used to search and display specific book. (Step 7-8)
8. update_book () Used to update the details of book. (Step 9)
9. allocate_book() It is used to allocate a book to user. (Step 10-11)
10. return_book() It is used to return the book from user. (Step 12)
11. account_block() It is used to block and activate an account for user. (13)
12. Library_statistics() It is used to display the statistics of library. (Step 13-14)
5. Testing:
Program is tested several times by using multiple inputs to check for any
logical or conceptual error. Here are the output screenshots to verify the testing
phase.
Main Panel:
Book Section:
User Manual:
This program is developed to manage library tasks. User can add, update records.
Main Section:
After running the program main section will appear. Use can choose to navigate to book
section, user section or library statistics.
Press B for Book Menu.
Press U for User Menu.
Press L for Library Statistics.
Press E to Exit.
Do not worry if wrong key is pressed. Program will show an invalid input message and
prompt the user to enter input again.
Book Section:
In book section user can add, update and search for books.
Press A to Add Book
Press D to Display List
Press S to Search
Press U to Update
Press M for Main Menu
Press E to Exit
Add Book:
In this section program will ask for the details of book and book will be stored in the
list.
Display Book
This option will display a list of all the present books.
Search Book
In this option program will ask the user to enter title or ISBN of book. If book found,
it will be displayed. Otherwise Not Found message will be shown.
Update Book
This option is used to update the details of existing book.
User Section:
In this section record of library user will be maintained and allotment of books will
be handled.
A to Add User
B to Allot Book
R to Return Book
P for Payment Account
D to Display List of Users
S to Search User & Display Statistics
U to Update User Info
M to Go To Main Menu
E to Exit
Add User
This option will prompt the user to enter user details to store it.
Allot Book
In this section program will ask the user to input username. If found, then it will ask
for book title or number. If found, it will ask for issue date and due date. After this the
book will issued to that specific user and can be seen from Search User & Display
Statistics option.
Return Book
In this option first program will ask for the username. If found, it will show the list of
allocated books to that user if any. From that list user will enter the serial number to
return the book. After entering, the book will be returned and can be confirmed from
Search User & Display Statistics option.
Payment Account
In this option the user can block or activate a user account. If account is activated, a
block option will be shown and of account is already blocked, an option to activate will
be displayed.
Display List of Users
This function is used to display the list of all users.
Search User & Display Statistics
This function shows the complete statistics for a user. In this option, user will be
asked to enter username. Complete detail of user along with complete detail of all books
allotted to that user will be shown.
Update User Info
In this option user can search for a specific registered user and his privileges can be
updated.
Library Section:
In this section the complete list of books and user will be shown.