-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
44 lines (41 loc) · 1.45 KB
/
Copy pathMain.java
File metadata and controls
44 lines (41 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
Library library=new Library();
while(true){
System.out.println("\n=== Library Management System ===");
System.out.println("1. Add Book");
System.out.println("2. View Books");
System.out.println("3. Search Book");
System.out.println("4. Exit");
System.out.print("Choice: ");
int ch=sc.nextInt();
sc.nextLine();
switch(ch){
case 1:
System.out.print("ID: ");
int id=sc.nextInt();
sc.nextLine();
System.out.print("Title: ");
String title=sc.nextLine();
System.out.print("Author: ");
String author=sc.nextLine();
library.addBook(new Book(id,title,author));
break;
case 2:
library.viewBooks();
break;
case 3:
System.out.print("Enter ID: ");
library.searchBook(sc.nextInt());
break;
case 4:
System.out.println("Goodbye!");
return;
default:
System.out.println("Invalid choice.");
}
}
}
}