-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.java
More file actions
63 lines (43 loc) · 1.56 KB
/
Copy pathlibrary.java
File metadata and controls
63 lines (43 loc) · 1.56 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.util.Scanner;
import java.util.ArrayList;
class library{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<String> books = new ArrayList<>();
int choice;
do {
System.out.println("\n1. Add Book");
System.out.println("2. View Books");
System.out.println("3. Remove Book");
System.out.println("4. Exit");
System.out.print("Enter Choice: ");
choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
System.out.print("Enter Book Name: ");
String book = sc.nextLine();
books.add(book);
System.out.println("Book Added");
break;
case 2:
System.out.println("Books List:");
for (int i = 0; i < books.size(); i++) {
System.out.println(books.get(i));
}
break;
case 3:
System.out.print("Enter Index to Remove: ");
int index = sc.nextInt();
books.remove(index);
System.out.println("Book Removed");
break;
case 4:
System.out.println("Thank You");
break;
default:
System.out.println("Invalid Choice");
}
} while (choice != 4);
}
}