Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Simple Library Management System Made By Rohan Joshi
- package com.company;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Scanner;
- class librarymanagement{
- ArrayList<String> addBk = new ArrayList< >();
- HashMap<String,String> iBook = new HashMap<>();
- public void issueBook(String Name , String Book){
- iBook.put(Name,Book);
- }
- public void preAddedBooks(){
- addBk.add("Maths");
- addBk.add("Science");
- addBk.add("English");
- }
- public void addBook( String aBook){
- addBk.add(aBook);
- }
- public void availableBook() {
- for (String avlBook : addBk) {
- System.out.println(avlBook);
- }
- }
- public void issuedBooks(){
- for(String issuedBook: iBook.keySet()){
- System.out.println(" "+issuedBook+" "+iBook.get(issuedBook)+" ");
- }
- }
- }
- public class library {
- public static void main(String[] args) {
- int ch;
- librarymanagement lm = new librarymanagement();
- Scanner sc = new Scanner(System.in);
- System.out.println("Welcome To Library Management System");
- lm.preAddedBooks();
- do {
- System.out.println("press 1 to Show Available Book");
- System.out.println("press 2 to Add book");
- System.out.println("press 3 to issue book");
- System.out.println("press 4 to see issued book");
- System.out.println("press 5 for Exit the program");
- ch = sc.nextInt();
- switch (ch) {
- case 1:
- System.out.println("Displaying Available Books");
- System.out.println("--------------------------------------------------------------");
- lm.availableBook();
- System.out.println("--------------------------------------------------------------");
- break;
- case 2:
- System.out.println("Name of book you want to Add");
- String ind = sc.next();
- lm.addBook(ind);
- System.out.println("--------------------------------------------------------------");
- break;
- case 3:
- System.out.println("Enter your name");
- String name = sc.next();
- System.out.println("Currently Available Books");
- System.out.println("--------------------------------------------------------------");
- lm.availableBook();
- System.out.println("--------------------------------------------------------------");
- System.out.println("Enter Book name you want to issue");
- String bookName = sc.next();
- boolean ifavailable = lm.addBk.contains(bookName);
- if (ifavailable) {
- lm.issueBook(name, bookName);
- System.out.println("Sucessfully Book is issued");
- }
- else{
- System.out.println("Currently this book is not available");
- }
- break;
- case 4:
- System.out.println("Showing ISSUED Books By Person and the book nme");
- System.out.println("--------------------------------------------------------------");
- System.out.println("---Person---------------------------------BookName-----------");
- lm.issuedBooks();
- System.out.println("--------------------------------------------------------------");
- break;
- case 5:
- System.out.println("Thanks for exiting the program.....");
- break;
- default:
- System.out.println("Please Select the correct option");
- }
- }while(ch!=5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement