Question 1-java_inventory
Question 1-java_inventory
Source Code:
import java.util.ArrayList;
import java.util.Scanner;
class Product {
int id;
String name;
int quantity;
double price;
this.id = id;
this.name = name;
this.quantity = quantity;
this.price = price;
@Override
return "ID: " + id + ", Name: " + name + ", Quantity: " + quantity + ", Price: $" + price;
while (true) {
System.out.println("5. Exit");
switch (choice) {
case 1:
addProduct();
break;
case 2:
viewProducts();
break;
case 3:
updateProduct();
break;
case 4:
deleteProduct();
break;
case 5:
return;
default:
int id = scanner.nextInt();
if (inventory.isEmpty()) {
} else {
System.out.println(product);
int id = scanner.nextInt();
found = true;
product.quantity = scanner.nextInt();
product.price = scanner.nextDouble();
break;
if (!found) {
int id = scanner.nextInt();
if (removed) {
} else {
}
Output:
Adding a Product:
Viewing Products:
Updating a Product:
Deleting a Product: