Consider how you might modularize the code in your project. What kind of data will the functions take as arguments and what kind of data will the functions return? Where will the functions be called? Modify your pseudocode and flowchart(s) from Module 04 by modularizing the program using functions as appropriate. You should continue working on translating your project’s pseudocode into C++ code and testing it.
Inventory Accounting Program – Pseudocode and Flowchart
Pseudocode
- Start
- Declare totalInventoryItems as Whole Number
- Set totalInventoryItems to 50
- Declare 1-Dimentional arraysItemCodes, ItemNames, ItemDescas Text with length of totalInventoryItems
- Declare 1-Dimentional arrays ItemQtyInStock, ItemQtySold as Whole Number of length of totalInventoryItems
- Declare 1-Dimentional arrays ItemWCost, ItemRCost as Fractional Numbers of length of totalInventoryItems
- Set ItemsListIndex = 0
- Declare variable myOptionas Whole Number
- Set myOption = 0
- Display Menu
- Display “1. Add Item to Inventory”
- Display “2. Remove Item from Inventory”
- Display “3. Edit Inventory Item”
- Display “4. Show Inventory Item Info”
- Display “5. Quit Program”
- Display “Enter your Choice”
- Read myOption
- While myOptionis not equal to 5
- If myOption is 1
- Display “Enter Item Info:”
- Read Item Code into ItemCode at ItemsListIndex
- Read Item Name into ItemName at ItemsListIndex
- Read Item Description into ItemDesc at ItemsListIndex
- Read the Wholesale Cost into ItemWCost at ItemsListIndex
- Read the Retail Cost into Item at ItemsListIndex
- Read the Quantity in Stock into ItemQtyInStock at ItemsListIndex
- Read the Quantity Sold into ItemQtySold at ItemsListIndex
- Set ItemsListIndex to ItemsListIndex + 1 at ItemsListIndex
- End If
- Else If myOption is 2
- Get Index of Item to Remove (Search the ItemCodes array)
- Declare ItemIndex as Whole Number
- Set ItemIndex to 0
- Declare inputCode as Text
- Display “Enter the Item Code”
- Read inputCode
- While ItemIndex is less than ItemsListIndex
- Traverse the ItemCodes array at ItemIndex position
- If ItemCode=inputCode
- Exit from Loop
- Get Index of Item to Remove (Search the ItemCodes array)
- End If
- Set ItemIndexto ItemIndex+ 1
- End While
- If ItemIndex = ItemsListIndex
- Display “No Match found”
- End If
- Else
- Declare Text as Choice
- Declare Choice as Empty
- Display “Are you sure you want to delete? Y or N”
- Input Choice
- If Choice is Y
- Declare Temp Text arrays of length totalInventoryItems for ItemNames and ItemDesc
- Declare Temp Fractional Number arrays of length totalInventoryItemsfor ItemWCost and ItemRCost
- Declare Temp Whole Number arrays of length totalInventoryItemsfor ItemQtyInStock and ItemQtySold
- Copy ItemCodes from 0 to ItemIndex-1 into Temp arrays
- Copy ItemCodes from ItemIndex+1 to ItemsListIndex -1 into Temp arrays
- Copy Temp arrays to ItemCodes array
- Repeat Steps 4 to 6 for ItemNames, ItemDesc, ItemWCost, ItemRCost, ItemQtyInStock and ItemQtySold arrays
- Set ItemsListIndex to ItemsListIndex– 1
- Display “Item Deleted Successfully”
- End If
- End Else
- End If
- Else If myOption is 3
- Get Index of Item to Edit (See Step C-i.)
- If ItemIndex = ItemsListIndex
- Display “No match found”
- End If
- Else
- Display “Leave prompt empty if do not want to edit”
- Declare Value as Text
- Set Value to Empty
- Declare Textname, desc,
- Declare Fractional Numbers wcost, rcost
- Declare Whole NumbersqtyInStock, qtySold
- Set name to ItemName at EditItemIndex
- Set desc to ItemDesc at EditItemIndex
- Set wcost to ItemWCost at EditItemIndex
- Set rcost to ItemRCost at EditItemIndex
- Set qtyInStock to ItemQtyInStock at EditItemIndex
- Set qtySold to ItemQtySold at EditItemIndex
- Display “Item Name” and name
- Read Value
- If Value is not Empty
- Replace name with value
- End If
- Repeat Step 11 to 14 for desc, Wcost, rcost, qtyInStock,QtySold
- Store variables from Step 4 to their respective arrays at ItemIndex
- End Else
- End If
- If myOption is 4
- Get Item Index to Show (Call Step C-i)
- If ItemIndex = ItemsListIndex
- Display “No match found”
- End If
- Else
- Display “Requested Item Information”
- Display Item Code
- Display Item Name
- Display Item Description
- Display Item Quantity
- Display Wholesale Cost
- Display Retail Cost
- Display Quantity in Stock
- Display Quantity Sold
- End Else
- End If
- Else
- Display “Invalid Option”
- End Else
- Display Menu from Step 10
- Display “Enter your Choice”
- Read myOption
- End While
- Display “Program Ended”
- Stop
Flowchart
Getting Custom Writing Service with any of your academic assignments is easy. Simply click here.