-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInventoryApp.java
More file actions
89 lines (70 loc) · 3.16 KB
/
Copy pathInventoryApp.java
File metadata and controls
89 lines (70 loc) · 3.16 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.util.Scanner;
public class InventoryApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
InventoryManager manager = new InventoryManager();
while (true) {
System.out.println("\n===== INVENTORY MANAGEMENT SYSTEM =====");
System.out.println("1. Add Product");
System.out.println("2. View Products");
System.out.println("3. Search Product");
System.out.println("4. Update Quantity");
System.out.println("5. Delete Product");
System.out.println("6. Total Inventory Value");
System.out.println("7. Show Low Stock Products");
System.out.println("8. Exit");
System.out.print("Choose option: ");
try {
int choice = sc.nextInt();
switch (choice) {
case 1:
System.out.print("Enter ID: ");
int id = sc.nextInt();
sc.nextLine();
System.out.print("Enter Name: ");
String name = sc.nextLine();
System.out.print("Enter Price: ");
double price = sc.nextDouble();
System.out.print("Enter Quantity: ");
int qty = sc.nextInt();
System.out.print("Enter Minimum Stock Level: ");
int min = sc.nextInt();
manager.addProduct(new Product(id, name, price, qty, min));
break;
case 2:
manager.viewProducts();
break;
case 3:
System.out.print("Enter ID to search: ");
Product p = manager.searchProduct(sc.nextInt());
System.out.println(p != null ? p : "❌ Product not found");
break;
case 4:
System.out.print("Enter ID: ");
int uid = sc.nextInt();
System.out.print("Enter new Quantity: ");
manager.updateQuantity(uid, sc.nextInt());
break;
case 5:
System.out.print("Enter ID to delete: ");
manager.deleteProduct(sc.nextInt());
break;
case 6:
manager.totalInventoryValue();
break;
case 7:
manager.showLowStockProducts();
break;
case 8:
System.out.println("👋 Exiting...");
return;
default:
System.out.println("❌ Invalid choice");
}
} catch (Exception e) {
System.out.println("⚠ Invalid input! Please try again.");
sc.nextLine();
}
}
}
}