0% found this document useful (0 votes)
2 views

Assignment1

The document outlines an Inventory Management System with functions to add new items, update item quantities, and generate inventory reports. It includes error handling for negative quantities and provides a menu for user interaction. The system continues to prompt the user until they choose to exit.

Uploaded by

Afshan Tabassum
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment1

The document outlines an Inventory Management System with functions to add new items, update item quantities, and generate inventory reports. It includes error handling for negative quantities and provides a menu for user interaction. The system continues to prompt the user until they choose to exit.

Uploaded by

Afshan Tabassum
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Inventory <- empty list to store item details (item_name, quantity)

Function DisplayMenu()
Print "Inventory Management System"
Print "1. Add New Item"
Print "2. Update Item Quantity"
Print "3. Generate Inventory Report"
Print "4. Exit"
Print "Enter your choice: "
End Function

Function AddNewItem()
Try
Print "Enter Item Name: "
item_name <- Input()
Print "Enter Item Quantity: "
quantity <- Integer(Input())
If quantity < 0 Then
Throw Exception("Quantity cannot be negative")
End If
Inventory.append([item_name, quantity])
Print "Item successfully added!"
Catch Exception as error
Print "Error: " + error.message
End Try
End Function

Function UpdateQuantity()
Try
Print "Enter Item Name to Update: "
item_name <- Input()
item_found <- False
For Each item in Inventory
If item[0] == item_name Then
Print "Current Quantity: " + item[1]
Print "Enter New Quantity: "
new_quantity <- Integer(Input())
If new_quantity < 0 Then
Throw Exception("Quantity cannot be negative")
End If
item[1] <- new_quantity
item_found <- True
Print "Quantity updated successfully!"
End If
End For
If item_found == False Then
Print "Item not found."
End If
Catch Exception as error
Print "Error: " + error.message
End Try
End Function

Assignment1.txt[2/7/2025 7:01:28 PM]


Function GenerateReport()
If Inventory is Empty Then
Print "No items in inventory."
Else
Print "Inventory Report:"
For Each item in Inventory
Print "Item Name: " + item[0] + ", Quantity: " + item[1]
End For
End If
End Function

Repeat
DisplayMenu()
choice <- Integer(Input())
Switch choice
Case 1:
AddNewItem()
Break
Case 2:
UpdateQuantity()
Break
Case 3:
GenerateReport()
Break
Case 4:
Print "Exiting System. Goodbye!"
Exit Program
Default:
Print "Invalid choice. Please try again."
End Repeat

Assignment1.txt[2/7/2025 7:01:28 PM]

You might also like