Add Item and Remove Item in Inventory
Add Item and Remove Item in Inventory
The system should allow the user to add product names to the inventory list, remove a product,
and then display the updated list of products. Since the number of products can vary, you decide
to use an ArrayList to store the product names.
Requirements:
· The program should allow the user to add new product names to an ArrayList.
CODE:-
using System;
using System.Collections;
class Program
productInventory.Add("Laptop");
productInventory.Add("Smartphone");
productInventory.Add("Headphones");
while (keepRunning)
Console.Clear();
Console.WriteLine("-------------------------");
Console.WriteLine("4. Exit");
switch (choice)
case "1":
productInventory.Add(newProduct);
break;
case "2":
if (productInventory.Contains(productToRemove))
productInventory.Remove(productToRemove);
else
break;
case "3":
break;
case "4":
keepRunning = false;
break;
default:
break;
Console.ReadKey();
}OUTPUT:-
-------------------------
4. Exit
-------------------------
4. Exit
- Laptop
- Smartphone
- Headphones
- phone