Programming Assingment Unit. 2
Programming Assingment Unit. 2
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
// Define a Book class to represent a book with title, author, and quantity
class Book {
private String title;
private String author;
private int quantity;
// Getter method for retrieving the quantity of the book available in the
library
public int getQuantity() {
return quantity;
}
// Main menu will loop to interact with the user until the "Exit"
option is chosen
while (!exit) {
System.out.println("Library System Menu:");
System.out.println("1. Add Books");
System.out.println("2. Borrow Books");
System.out.println("3. Return Books");
System.out.println("4. Exit");
System.out.print("Select an option: ");
switch (choice) {
case 1:
addBooks();
break;
case 2:
borrowBooks();
break;
case 3:
returnBooks();
break;
case 4:
exit = true; // Set exit flag to true to terminate the
program
System.out.println("Exiting Library System. Goodbye!");
break;
default:
System.out.println("Invalid option. Please try again.");
break;
}
}
OUTPUT: