Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- //global variables
- int role,i = 0;
- char full_name[50],student_no[50],emp_no[50];
- int rb1=0,rb2=0,rb3=0,rb4=0,rb5=0;//reserve books
- int bb1=0,bb2=0,bb3=0,bb4=0,bb5=0;//borrow books
- char returnBooks[100];
- void menu();
- void borrow();
- void reserve();
- void review();
- int main(){
- printf("LIBRAY SYSTEM MANAGEMENT ...\n");
- printf("Are you ? \n[1] student \n[2] employer\n ~");
- scanf("%d",&role);
- fflush(stdin);
- if(role == 1){
- printf("Enter your name ~ ");
- gets(full_name);
- printf("Enter your student number ~ ");
- gets(student_no);
- }else if(role == 2){
- printf("Enter you id number ~");
- gets(emp_no);
- }else {
- getch();
- system("cls");
- return 0;
- }
- menu();
- return 0;
- }
- void reserve(){
- int choice;
- while(1){
- system("cls");
- printf("AVAILABLE BOOKS\n--------------------\n");
- printf("Book# Name\n");
- if(rb1 != 1) printf("1 mathematics\n");
- if(rb2 != 2) printf("2 Arts\n");
- if(rb3 != 3) printf("3 Science\n");
- if(rb4 != 4) printf("4 English\n");
- if(rb5 != 5) printf("5 MAPEH\n");
- if(rb1 == 1&&rb2 == 2&&rb3 == 3&&rb4 == 4&&rb5 == 5){
- printf("NO AVAILABLE BOOKS TO RESERVE!");
- getch();
- menu();
- }
- printf("Enter the Book# you want to reserve, enter [9] to back to menu~ ");
- scanf("%d",&choice);
- fflush(stdin);
- if(choice == 9)menu();
- if(choice == 1) {
- rb1 = 1;
- continue;
- }
- if(choice == 2){
- rb2 = 2;
- continue;
- }
- if(choice == 3){
- rb3 = 3;
- continue;
- }
- if(choice == 4){
- rb4 = 4;
- continue;
- }
- if(choice == 5){
- rb5 = 5;
- continue;
- }
- else printf("not available !\n");
- }
- }
- void review(){
- system("cls");
- if(role == 1){
- printf("Type : Student\nName : %s\nStudent # : %s\n\n",full_name,student_no);
- }else {
- printf("Type : Employer\nId# : %s\n\n",emp_no);
- }
- printf("Reserved books \n");
- if(rb1 != 0){
- printf("-book 1 mathematics\n");
- }
- if(rb2 != 0){
- printf("-book 2 Arts\n");
- }
- if(rb3 != 0){
- printf("-book 3 Science\n");
- }
- if(rb4 != 0){
- printf("-book 4 English\n");
- }
- if(rb5 != 0){
- printf("-book 5 Mapeh\n");
- }
- printf("\nBorrowed books \n");
- if(bb1 != 0){
- printf("-book 1 ethics\n");
- }
- if(bb2 != 0){
- printf("-book 2 Rizal\n");
- }
- if(bb3 != 0){
- printf("-book 3 Programming\n");
- }
- if(bb4 != 0){
- printf("-book 4 Arts\n");
- }
- if(bb5 != 0){
- printf("-book 5 Computing\n");
- }
- printf("\nReturned Books \n%s",returnBooks);
- getch();
- menu();
- }
- void borrow(){
- int choice;
- while(1){
- system("cls");
- printf("AVAILABLE BOOKS\n--------------------\n");
- printf("Book# Name\n");
- if(bb1 != 1) printf("1 Ethics\n");
- if(bb2 != 2) printf("2 Rizal\n");
- if(bb3 != 3) printf("3 Programming\n");
- if(bb4 != 4) printf("4 Arts\n");
- if(bb5 != 5) printf("5 Computing\n");
- if(bb1 == 1&&bb2 == 2&&bb3 == 3&&bb4 == 4&&bb5 == 5){
- printf("NO AVAILABLE BOOKS TO BORROW!");
- getch();
- menu();
- }
- printf("Enter the Book# you want to borrow, enter [9] to back to menu~ ");
- scanf("%d",&choice);
- fflush(stdin);
- if(choice == 9)menu();
- if(choice == 1) {
- bb1 = 1;
- continue;
- }
- if(choice == 2){
- bb2 = 2;
- continue;
- }
- if(choice == 3){
- bb3 = 3;
- continue;
- }
- if(choice == 4){
- bb4 = 4;
- continue;
- }
- if(choice == 5){
- bb5 = 5;
- continue;
- }
- else printf("not available !\n");
- getch();
- }
- }
- void rBooks(){
- int choice;
- while(1){
- system("cls");
- printf("RETURN BOOKS\n--------------------\n");
- printf("Book# Name\n");
- if(bb1 == 1) printf("1 Ethics\n");
- if(bb2 == 2) printf("2 Rizal\n");
- if(bb3 == 3) printf("3 Programming\n");
- if(bb4 == 4) printf("4 Arts\n");
- if(bb5 == 5) printf("5 Computing\n");
- if(bb1 != 1&&bb2 != 2&&bb3 != 3&&bb4 != 4&&bb5 != 5){
- printf("NO AVAILABLE BOOKS TO RETURN!");
- getch();
- menu();
- }
- printf("Enter the Book# you want to Return, enter [9] to back to menu~ ");
- scanf("%d",&choice);
- fflush(stdin);
- if(choice == 9)menu();
- if(choice == 1) bb1 = 0;
- if(choice == 2) bb2 = 0;
- if(choice == 3) bb3 = 0;
- if(choice == 4) bb4 = 0;
- if(choice == 5) bb5 = 0;
- else printf("not available !\n");
- getch();
- }
- }
- void menu(){
- int choose;
- char ch;
- system("cls");
- printf("-----MENU----\n");
- printf("Options ~\n[1] reservation book \n[2] borrow book\n[3] return book \n[4] Review Books\n[5] Exit\n~ ");
- scanf("%d",&choose);
- fflush(stdin);
- if(choose == 1){
- reserve();
- }if(choose == 2){
- borrow();
- }else if(choose == 3){
- rBooks();
- }else if(choose == 4)review();
- else if(choose == 5) {
- printf("end session ! Thank you for using library system!");
- getch();
- system("cls");
- exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement