rohanaj60

Simple Library Management System(RNZ)

Jul 30th, 2021
808
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Simple Library Management System Made By Rohan Joshi
  2.  
  3. package com.company;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import java.util.Scanner;
  8.  
  9.  class librarymanagement{
  10.      ArrayList<String> addBk = new ArrayList< >();
  11.      HashMap<String,String> iBook  = new HashMap<>();
  12.   public void issueBook(String Name , String Book){
  13.  
  14.         iBook.put(Name,Book);
  15.     }
  16.     public void preAddedBooks(){
  17.       addBk.add("Maths");
  18.         addBk.add("Science");
  19.         addBk.add("English");
  20.     }
  21.    public void addBook( String aBook){
  22.  
  23.         addBk.add(aBook);
  24.  
  25.     }
  26.     public void availableBook() {
  27.         for (String avlBook : addBk) {
  28.             System.out.println(avlBook);
  29.         }
  30.     }
  31.         public void issuedBooks(){
  32.             for(String issuedBook: iBook.keySet()){
  33.  
  34.                 System.out.println("   "+issuedBook+"                                  "+iBook.get(issuedBook)+"           ");
  35.             }
  36.     }
  37. }
  38. public class library {
  39.     public static void main(String[] args) {
  40.         int ch;
  41. librarymanagement lm = new librarymanagement();
  42.         Scanner sc = new Scanner(System.in);
  43.         System.out.println("Welcome To Library Management System");
  44.         lm.preAddedBooks();
  45. do {
  46.     System.out.println("press 1 to Show Available Book");
  47.     System.out.println("press 2 to Add book");
  48.     System.out.println("press 3 to issue book");
  49.     System.out.println("press 4 to see issued book");
  50.     System.out.println("press 5 for Exit the program");
  51.     ch = sc.nextInt();
  52.     switch (ch) {
  53.         case 1:
  54.             System.out.println("Displaying Available Books");
  55.             System.out.println("--------------------------------------------------------------");
  56.             lm.availableBook();
  57.             System.out.println("--------------------------------------------------------------");
  58.             break;
  59.         case 2:
  60.             System.out.println("Name of book you want to Add");
  61.             String ind = sc.next();
  62.             lm.addBook(ind);
  63.             System.out.println("--------------------------------------------------------------");
  64.             break;
  65.         case 3:
  66.             System.out.println("Enter your name");
  67.             String name = sc.next();
  68.             System.out.println("Currently Available Books");
  69.             System.out.println("--------------------------------------------------------------");
  70.             lm.availableBook();
  71.             System.out.println("--------------------------------------------------------------");
  72.             System.out.println("Enter Book name you want to issue");
  73.  
  74.             String bookName = sc.next();
  75.             boolean ifavailable = lm.addBk.contains(bookName);
  76.             if (ifavailable) {
  77.                 lm.issueBook(name, bookName);
  78.                 System.out.println("Sucessfully Book is issued");
  79.             }
  80.             else{
  81.                 System.out.println("Currently this book is not available");
  82.             }
  83.             break;
  84.         case 4:
  85.             System.out.println("Showing ISSUED Books By Person and the book nme");
  86.             System.out.println("--------------------------------------------------------------");
  87.             System.out.println("---Person---------------------------------BookName-----------");
  88.             lm.issuedBooks();
  89.             System.out.println("--------------------------------------------------------------");
  90.  
  91.             break;
  92.         case 5:
  93.             System.out.println("Thanks for exiting the program.....");
  94.             break;
  95.         default:
  96.             System.out.println("Please Select the correct option");
  97.     }
  98. }while(ch!=5);
  99.     }
  100. }
  101.  
RAW Paste Data