fork download
  1. import java.util.Scanner;
  2.  
  3. public class LibraryManagementSystem {
  4.  
  5. // Classes for Book, Student, and Library Management
  6. static class Book {
  7. private int sNo;
  8. private String bookName;
  9. private String authorName;
  10. private int bookQty;
  11. private int bookQtyCopy;
  12. private String bookType; // New field for book type
  13.  
  14. public Book() {
  15. Scanner input = new Scanner(System.in);
  16. System.out.print("Enter Serial No of Book: ");
  17. this.sNo = input.nextInt();
  18. input.nextLine(); // Clear buffer
  19.  
  20. System.out.print("Enter Book Name: ");
  21. this.bookName = input.nextLine();
  22.  
  23. System.out.print("Enter Author Name: ");
  24. this.authorName = input.nextLine();
  25.  
  26. System.out.print("Enter Quantity of Books: ");
  27. this.bookQty = input.nextInt();
  28. this.bookQtyCopy = this.bookQty;
  29. input.nextLine(); // Clear buffer
  30.  
  31. System.out.print("Enter Book Type (e.g., Fiction, Non-Fiction, Science, History): ");
  32. this.bookType = input.nextLine(); // New input for book type
  33. }
  34.  
  35. public int getsNo() { return sNo; }
  36. public String getBookName() { return bookName; }
  37. public String getAuthorName() { return authorName; }
  38. public int getBookQty() { return bookQty; }
  39. public int getBookQtyCopy() { return bookQtyCopy; }
  40. public String getBookType() { return bookType; } // Getter for book type
  41.  
  42. public void addBookQty(int qty) {
  43. this.bookQty += qty;
  44. this.bookQtyCopy += qty;
  45. }
  46. }
  47.  
  48. static c
  49.  
Success #stdin #stdout 0.03s 25980KB
stdin
Standard input is empty
stdout
import java.util.Scanner;

public class LibraryManagementSystem {

    // Classes for Book, Student, and Library Management
    static class Book {
        private int sNo;
        private String bookName;
        private String authorName;
        private int bookQty;
        private int bookQtyCopy;
        private String bookType;  // New field for book type

        public Book() {
            Scanner input = new Scanner(System.in);
            System.out.print("Enter Serial No of Book: ");
            this.sNo = input.nextInt();
            input.nextLine(); // Clear buffer

            System.out.print("Enter Book Name: ");
            this.bookName = input.nextLine();

            System.out.print("Enter Author Name: ");
            this.authorName = input.nextLine();

            System.out.print("Enter Quantity of Books: ");
            this.bookQty = input.nextInt();
            this.bookQtyCopy = this.bookQty;
            input.nextLine(); // Clear buffer

            System.out.print("Enter Book Type (e.g., Fiction, Non-Fiction, Science, History): ");
            this.bookType = input.nextLine(); // New input for book type
        }

        public int getsNo() { return sNo; }
        public String getBookName() { return bookName; }
        public String getAuthorName() { return authorName; }
        public int getBookQty() { return bookQty; }
        public int getBookQtyCopy() { return bookQtyCopy; }
        public String getBookType() { return bookType; } // Getter for book type

        public void addBookQty(int qty) {
            this.bookQty += qty;
            this.bookQtyCopy += qty;
        }
    }

    static c