Inventory Management System
VerifiedAdded on 2019/10/16
|5
|2171
|260
Report
AI Summary
In this assignment, we are asked to create a program that allows users to manage an inventory of items. The program will include menu options for adding, deleting, and displaying items. We will also implement additional features such as serial lookup by name, duplicate detection, larger arrays with page-by-page display, item changes, and data file input/output.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Galaxy of Geckos Inventory Management System
Summary
The Galaxy of Geckos Inventory Management System displays data from a sequential file to the
screen, and then displays a menu. The user can choose to add a new item, change an existing
item, delete an item, create a report or exit the program. When the program exits, the same
sequential data file will be written with the current data stored in the arrays.
There are extra credit opportunities available for this project listed at the end of the
instructions.
General Requirements
1. Sequential data file as input – You must use a sequential data file as input to the program.
You may use the one provided, or create your own. If you create your own, it must follow
the same format as the example file. This data file stores three pieces of data: the name of
the inventory item stored as a string, the amount of the item in inventory stored as a
number, and the cost of the item stored as a number. Note that this data file DOES NOT
have a data terminating value like “END” or 00. Therefore, you must use the EOF function as
the condition of your loop when getting the data from it. Important! Close this file as soon
as you are done reading it. See #5 below for why.
2. Parallel arrays for storage while the program is running – You must use three parallel
arrays to store the data input from the file: a string array for the item names, an integer
array for the amounts of each item, and single-precision array for the item costs. Use a size
of 10 for the arrays.
3. Displaying the array data – After the arrays are loaded, print headings to the screen, and
then print the data in the arrays to the screen. To print the data to the screen, loop through
the names array, and if an item name is not equal to the empty string, then calculate the
total value (amount of the item * cost per item). Print each item’s subscript, name, amount,
cost per item and total value to the screen.
4. Menu – You must display the style of menu as displayed below, which uses letters for the
menu choices. After the user’s choice has been handled, redisplay the headings, array data,
and the menu (except for when the user chooses to exit the program, as noted below.)
5. Add, change or delete items in inventory – The program must be able to add a new item to
inventory, change an existing item, or delete an item. See below for more details on these
requirements.
6. Sequential file as a report – If the user chooses to print an inventory report, print the
output to a nicely-formatted sequential output file. Use a different file than the one you use
for input.
7. Sequential data file as output – When the program exits, write the current contents of the
array to the same file that you used for input. Remember that you will have to open this file
Summary
The Galaxy of Geckos Inventory Management System displays data from a sequential file to the
screen, and then displays a menu. The user can choose to add a new item, change an existing
item, delete an item, create a report or exit the program. When the program exits, the same
sequential data file will be written with the current data stored in the arrays.
There are extra credit opportunities available for this project listed at the end of the
instructions.
General Requirements
1. Sequential data file as input – You must use a sequential data file as input to the program.
You may use the one provided, or create your own. If you create your own, it must follow
the same format as the example file. This data file stores three pieces of data: the name of
the inventory item stored as a string, the amount of the item in inventory stored as a
number, and the cost of the item stored as a number. Note that this data file DOES NOT
have a data terminating value like “END” or 00. Therefore, you must use the EOF function as
the condition of your loop when getting the data from it. Important! Close this file as soon
as you are done reading it. See #5 below for why.
2. Parallel arrays for storage while the program is running – You must use three parallel
arrays to store the data input from the file: a string array for the item names, an integer
array for the amounts of each item, and single-precision array for the item costs. Use a size
of 10 for the arrays.
3. Displaying the array data – After the arrays are loaded, print headings to the screen, and
then print the data in the arrays to the screen. To print the data to the screen, loop through
the names array, and if an item name is not equal to the empty string, then calculate the
total value (amount of the item * cost per item). Print each item’s subscript, name, amount,
cost per item and total value to the screen.
4. Menu – You must display the style of menu as displayed below, which uses letters for the
menu choices. After the user’s choice has been handled, redisplay the headings, array data,
and the menu (except for when the user chooses to exit the program, as noted below.)
5. Add, change or delete items in inventory – The program must be able to add a new item to
inventory, change an existing item, or delete an item. See below for more details on these
requirements.
6. Sequential file as a report – If the user chooses to print an inventory report, print the
output to a nicely-formatted sequential output file. Use a different file than the one you use
for input.
7. Sequential data file as output – When the program exits, write the current contents of the
array to the same file that you used for input. Remember that you will have to open this file
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
for output this time, so be sure it is closed after you read its contents into the arrays as
noted in requirement #1 above.
8. Subroutines are mandatory! – You must use subroutines in your program for full credit.
Believe me, it will be much easier if you do. Remember the purpose of subroutines is to be
able to repeat a set of statements without having to copy and paste or retype.
Menu Options
1) Menu Choice “A” – If the user chooses to Add Item to Inventory, perform the following
actions:
a) Clear the screen.
b) Determine if the arrays are already full. See the section Finding an Empty Position in
the Arrays.
c) If there isn’t enough room to add another item, print an error message.
d) If it’s ok to add another item, then prompt the user for the new item’s name, amount
and cost. Input these values directly into the open position in the arrays.
2) Menu Choice “C” – If the user chooses to Change an Existing Item, perform the following
actions:
a) Clear the screen.
b) Prompt the user for the item number that they wish to change.
c) If the item number entered by the user is not a valid item number (it is less than 1, or
greater than 10), print an error message.
d) If the item number is a valid subscript to the arrays, then prompt the user for the item’s
new name, new amount and new cost. Input these values directly into the appropriate
positions in the arrays.
3) Menu Choice “D” – If the user chooses to Delete an Item from Inventory, perform the
following actions:
a) Clear the screen.
b) Prompt the user for the item number that they wish to delete.
c) If the item number entered by the user is not a valid item number (it is less than 1, or
greater than 10), print an error message.
d) If the item number is a valid subscript to the arrays, then change the data in the
appropriate positions in the arrays. In the item names array, set the appropriate
element to "" (an empty string). In the numeric arrays, set the appropriate element to 0.
4) Menu Choice “P” – If the user chooses to print the inventory report to a file, perform the
following actions:
a) Clear the screen.
b) Open a sequential file as output. Note – do not use the same file as you use to store the
data. This should be a completely different file. Also note that you must use PRINT
statements to write this report to a file.
c) Print the appropriate headings to the file.
d) Loop through the arrays:
noted in requirement #1 above.
8. Subroutines are mandatory! – You must use subroutines in your program for full credit.
Believe me, it will be much easier if you do. Remember the purpose of subroutines is to be
able to repeat a set of statements without having to copy and paste or retype.
Menu Options
1) Menu Choice “A” – If the user chooses to Add Item to Inventory, perform the following
actions:
a) Clear the screen.
b) Determine if the arrays are already full. See the section Finding an Empty Position in
the Arrays.
c) If there isn’t enough room to add another item, print an error message.
d) If it’s ok to add another item, then prompt the user for the new item’s name, amount
and cost. Input these values directly into the open position in the arrays.
2) Menu Choice “C” – If the user chooses to Change an Existing Item, perform the following
actions:
a) Clear the screen.
b) Prompt the user for the item number that they wish to change.
c) If the item number entered by the user is not a valid item number (it is less than 1, or
greater than 10), print an error message.
d) If the item number is a valid subscript to the arrays, then prompt the user for the item’s
new name, new amount and new cost. Input these values directly into the appropriate
positions in the arrays.
3) Menu Choice “D” – If the user chooses to Delete an Item from Inventory, perform the
following actions:
a) Clear the screen.
b) Prompt the user for the item number that they wish to delete.
c) If the item number entered by the user is not a valid item number (it is less than 1, or
greater than 10), print an error message.
d) If the item number is a valid subscript to the arrays, then change the data in the
appropriate positions in the arrays. In the item names array, set the appropriate
element to "" (an empty string). In the numeric arrays, set the appropriate element to 0.
4) Menu Choice “P” – If the user chooses to print the inventory report to a file, perform the
following actions:
a) Clear the screen.
b) Open a sequential file as output. Note – do not use the same file as you use to store the
data. This should be a completely different file. Also note that you must use PRINT
statements to write this report to a file.
c) Print the appropriate headings to the file.
d) Loop through the arrays:
i) If an item name is not equal to the empty string, then:
(1) Calculate the total value (amount of the item * cost per item).
(2) Print each item’s subscript, name, amount, cost per item and total value to the
file.
(3) Add the amount of each item to a grand total of amounts.
(4) Add the total value of each item to a grand total of values.
e) After you print everything in the arrays, print the totals to the file.
f) Close the file.
g) Display a message to the screen, indicating the report has been created and to press
enter to return to the menu.
5) Menu Choice “X” – If the user chooses to exit the program, perform the following actions:
a) See “Sequential data file as output” above. Note that this output file should be written
to using WRITE statements. DO NOT add terminating data such as “END”.
b) End the program.
Finding An Empty Position in the Arrays
Adding or removing an entire element in an array—in other words, changing the array size from
10 to 9, or from 10 to 11, while the program is running—is not allowed in BASIC. In order to
“delete” an item from our inventory, we’re just setting the values at its location in the array to
null values (the empty string and 0). So our array of item names, for example, could look like
this, after a “deletion”:
NameArray$
Item Item Item Item
1 2 3 4 5 6 7 8 9 10
In the above picture, elements 2, 6, 7, 8, 9 and 10 are empty, and therefore are available to be
used. The array elements at subscripts 1, 3, 4, and 5 are full, and therefore can’t be used for
new items.
If we just kept a count of items in our array, and added 1 to the count when we added a new
item, or subtracted 1 from the count when we deleted an item, the current count for this array
would be 4. If we decided that the next new item should go at position 5, we would overwrite
data that already exists at position 5.
So a better approach that takes into account that we might have empty elements in between
full elements, is to perform a sequential search on one of the arrays, and look for an “empty”
position. The pseudocode for one way to do this is:
Set the variable IndexOfFirstEmptyPosition to -1
Loop through the names array from beginning to end (a for/next loop would work)
(1) Calculate the total value (amount of the item * cost per item).
(2) Print each item’s subscript, name, amount, cost per item and total value to the
file.
(3) Add the amount of each item to a grand total of amounts.
(4) Add the total value of each item to a grand total of values.
e) After you print everything in the arrays, print the totals to the file.
f) Close the file.
g) Display a message to the screen, indicating the report has been created and to press
enter to return to the menu.
5) Menu Choice “X” – If the user chooses to exit the program, perform the following actions:
a) See “Sequential data file as output” above. Note that this output file should be written
to using WRITE statements. DO NOT add terminating data such as “END”.
b) End the program.
Finding An Empty Position in the Arrays
Adding or removing an entire element in an array—in other words, changing the array size from
10 to 9, or from 10 to 11, while the program is running—is not allowed in BASIC. In order to
“delete” an item from our inventory, we’re just setting the values at its location in the array to
null values (the empty string and 0). So our array of item names, for example, could look like
this, after a “deletion”:
NameArray$
Item Item Item Item
1 2 3 4 5 6 7 8 9 10
In the above picture, elements 2, 6, 7, 8, 9 and 10 are empty, and therefore are available to be
used. The array elements at subscripts 1, 3, 4, and 5 are full, and therefore can’t be used for
new items.
If we just kept a count of items in our array, and added 1 to the count when we added a new
item, or subtracted 1 from the count when we deleted an item, the current count for this array
would be 4. If we decided that the next new item should go at position 5, we would overwrite
data that already exists at position 5.
So a better approach that takes into account that we might have empty elements in between
full elements, is to perform a sequential search on one of the arrays, and look for an “empty”
position. The pseudocode for one way to do this is:
Set the variable IndexOfFirstEmptyPosition to -1
Loop through the names array from beginning to end (a for/next loop would work)
If the item at the current element in the array is empty (= to the empty string)
Set the variable IndexOfFirstEmptyPosition to the subscript of this element
After this loop completes, if IndexOfFirstEmptyPosition is still -1, then you know there is no
more room in the array. None of the elements matched the empty string. But if
IndexOfFirstEmptyPosition is a different value, you know that that value is the location of an
empty position in the array.
Other Information
Your Galaxy of Geckos program for homework 5 may be a useful starting point for this
assignment.
You may use any kind of loops that work, except for the loop that gets the input from the file.
That loop must be a DO UNTIL loop as in the example on p. 366.
You must submit ONE planning tool for this assignment – either a hierarchy chart, a flowchart
or pseudocode. The pseudocode can be a plain text file or a Word document. The charts can be
Word documents, draw.io files (exported to png or jpg), or pictures of handwritten charts.
You can download the executable version of this program, and sample files, by clicking the link
on the assignment page. Note – this program can be executed by double-clicking on it. It is not
viewable in BASIC. The program assumes the data and report files are in the same folder as the
executable file. The data and report files can be opened in any text editor. If you choose to
create a new data file, DO NOT USE MICROSOFT WORD. Use a plain text editor like Notepad or
Notepad++.
Submit your BASIC file (.bas file extension), and your planning tool to the dropbox on Canvas.
You do not need to submit the data or report files.
Extra Credit Opportunities
Sorting – Before displaying the data to the screen, or printing it to the report, sort it by the item
name. (Max 3 points)
Report – Ask the user if the inventory report should go to screen or file. Send the report to the
appropriate output location. (Max 3 points)
Serial lookup by name – For change or delete, instead of asking for item number, ask for item
name and perform serial lookup. (Max 6 points)
Duplicates – Don’t allow duplicate item names to be added. (Max 6 points)
Larger arrays – Create arrays larger than 10, and then display data a page at a time. (Max 4
points)
Changing an item – Do not allow the user to change an empty item. Print an error message if
the user attempts to change an item that is empty. (Max 4 points)
Set the variable IndexOfFirstEmptyPosition to the subscript of this element
After this loop completes, if IndexOfFirstEmptyPosition is still -1, then you know there is no
more room in the array. None of the elements matched the empty string. But if
IndexOfFirstEmptyPosition is a different value, you know that that value is the location of an
empty position in the array.
Other Information
Your Galaxy of Geckos program for homework 5 may be a useful starting point for this
assignment.
You may use any kind of loops that work, except for the loop that gets the input from the file.
That loop must be a DO UNTIL loop as in the example on p. 366.
You must submit ONE planning tool for this assignment – either a hierarchy chart, a flowchart
or pseudocode. The pseudocode can be a plain text file or a Word document. The charts can be
Word documents, draw.io files (exported to png or jpg), or pictures of handwritten charts.
You can download the executable version of this program, and sample files, by clicking the link
on the assignment page. Note – this program can be executed by double-clicking on it. It is not
viewable in BASIC. The program assumes the data and report files are in the same folder as the
executable file. The data and report files can be opened in any text editor. If you choose to
create a new data file, DO NOT USE MICROSOFT WORD. Use a plain text editor like Notepad or
Notepad++.
Submit your BASIC file (.bas file extension), and your planning tool to the dropbox on Canvas.
You do not need to submit the data or report files.
Extra Credit Opportunities
Sorting – Before displaying the data to the screen, or printing it to the report, sort it by the item
name. (Max 3 points)
Report – Ask the user if the inventory report should go to screen or file. Send the report to the
appropriate output location. (Max 3 points)
Serial lookup by name – For change or delete, instead of asking for item number, ask for item
name and perform serial lookup. (Max 6 points)
Duplicates – Don’t allow duplicate item names to be added. (Max 6 points)
Larger arrays – Create arrays larger than 10, and then display data a page at a time. (Max 4
points)
Changing an item – Do not allow the user to change an empty item. Print an error message if
the user attempts to change an item that is empty. (Max 4 points)
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Deleting an item – Do not allow the user to delete an empty item. Print an error message if the
user attempts to delete an item that is already empty. (Max 4 points)
Ask the user for data file name – Ask the user for the input data file name. If the file doesn’t
exist, print an error message and ask for the file name again. (Max 4 points)
If you have any other ideas for extra credit, let me know.
user attempts to delete an item that is already empty. (Max 4 points)
Ask the user for data file name – Ask the user for the input data file name. If the file doesn’t
exist, print an error message and ask for the file name again. (Max 4 points)
If you have any other ideas for extra credit, let me know.
1 out of 5
Related Documents
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024 | Zucol Services PVT LTD | All rights reserved.