ProductsLogo
LogoStudy Documents
LogoAI Grader
LogoAI Answer
LogoAI Code Checker
LogoPlagiarism Checker
LogoAI Paraphraser
LogoAI Quiz
LogoAI Detector
PricingBlogAbout Us
logo

MS5 Open Submission

Verified

Added on  2019/09/16

|43
|13942
|546
Report
AI Summary
The provided content appears to be a table of items, including SKU numbers, names, prices, tax status, quantities, and total costs. The grand total is 2524.61. The program allows users to list all items, search by SKU, checkout an item, stock an item, add new items or update existing ones, and exit the program.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
1
Fall 2016.
Grocery Store Inventory System
File IO and Final assembly
IPC44 Project (Milestone 5, Due Fri Dec 9th 23:59, see project webpage)
(V1.1, corrected the datefile definitions and added comments.txt to OPEN submission)
In a grocery store, in order to be able to always have the proper number of items available on
shelves, an inventory system is needed to keep track of items available in the inventory and
make sure the quantity of the items does not fall below a specific count.
Your job for this project is to prepare an application that manages the inventory of items
needed for a grocery store. The application should be able to keep track of the following
information about an item:
1- The SKU number
2- The name (maximum of 20 chars)
3- Quantity (On hand quantity currently available in the inventory)
4- Minimum Quantity (if the quantity of the item falls less than or equal to this value, a
warning should be generated)
5- Price of the item
6- Is the item Taxed
This application must be able to do the following tasks:
1- Print a detailed list of all the items in the inventory
2- Search and display an item by its SKU number
3- Checkout an item to be delivered to the shelf for sale
4- Add to stock items that are recently purchased for inventory (add to their quantity)
5- Add a new item to the inventory or update an already existing item
6- Delete an item from the inventory (optional for extra marks)
7- Search for an item by its name (optional for extra marks)
8- Sort Items by Name (optional for extra marks)
PROJECT DEVELOPMENT PROCESS
To make the development of this application fun and easy, the tasks are broken down into
several functions that are given to you from very easy ones to more complicated one by the
end of the project
Since you act like a programmer in this project, you do not need to know the big picture. The
professor is your system analyst and designs the system and all its functions to work together in
harmony. Each milestone is divided into a few functions. For each function, firstly, understand
the goal of the function. Secondly, write the code for it and test it with the tester. Once your

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
2
code for the function passes the test, set it aside and pick up the next function. Continue until
the milestone is complete.
The Development process of the project is divided into six milestones and therefore six
deliverables. The first five deliverables are mandatory and conclude full submission of the
project. The sixth milestone is optional; for those who want to do some extra work for the
challenge and the bonus marks. For each deliverable, a tester program (also called a unit test)
will be provided to you to test your functions. If the tester works the way it is supposed to do,
you can submit that milestone and start the next. The approximate schedule for deliverables is
as follows
Kickoff week 7
The UI Tools Due in 10 days
The Application User Interface Due 5 days after UI
The Item IO Due 7 days after Application User Interface
Item Storage and Retrieval in Array Due 10 days after Item IO
File IO and final assembly Due 5 days after Item Storage (project completed)
Item Search by name, delete and sort (optional) 7 days after Project completion
FILE STRUCTURE OF THE PROJECT
For each milestone, a source file is provided under the name ipc_msX.c that includes the main()
tester program. (Replace X with the milestone number from 1 to 6)
The main program acts like a tester (a unit test). Code your functions in this file and test them
one by one using the main function provided. You can comment out the parts of the main
program for which functions are not developed yet. You are not allowed to change the code in
tester. Make sure you do not make any modifications in the tester.
MARKING:
Please follow this link for marking details:
https://scs.senecac.on.ca/~ipc144/dynamic/assignments/Marking_Rubric.pdf
MILESTONE 1: THE USER INTERFACE TOOLS (DUE SAT OCT 29TH)
Download or Clone milestone 1 from https://github.com/Seneca-144100/IPC_MS1
In ipc_ms1.c write the following functions:
void welcome(void);
Prints the following line and goes to newline
>---=== Grocery Inventory System ===---<
void prnTitle(void);
Document Page
3
Prints the following two lines and goes to newline
>Row |SKU| Name | Price |Taxed| Qty | Min | Total |Atn<
>----+---+--------------------+--------+-----+-----+-----+------------|---<
void prnFooter(double gTotal);
Prints the following line and goes to newline
>--------------------------------------------------------+----------------<
Then if gTotal is greater than zero it will print this line: (assuming gTotal is 1234.57) and
go to new line.
> Grand Total: | 1234.57<
Use this format specifier for printing gTotal : %12.2lf
void clrKyb(void);
“clear Keyboard” Makes sure the keyboard is clear by reading from keyboard character
by character until it reads a new line character.
Hint: In a loop, keep reading single characters from keyboard until newline character is
read ('\n'). Then, exit the loop.
void pause(void);
Pauses the execution of the application by printing a message and waiting for user to hit
<ENTER>.
Print the following line and DO NOT go to newline:
>Press <ENTER> to continue...<
Then, call clrKyb function.
Here the clrKyb function is used for a fool-proof <ENTER> key entry.
int getInt(void);
Gets a valid integer from the keyboard and returns it. If the integer is not valid it will
print:
"Invalid integer, please try again: "
and try again.
This function must be fool-proof; it should not let the user pass, unless a valid integer is
entered.
Hint: to do this, you can have two variables read back to back by scanf; an integer and then a character ("%d
%c") and make sure the second (the character) is new line. If the second character is new line, then this
guaranties that first integer is successfully read and also after the integer <ENTER> is hit. If the character is
anything but new line, then either the user did not enter an integer properly, or has some additional
characters after the integer, which is not good. In this case clear the keyboard, print an error message and
scan the integer again. See the flowchart below.
Document Page
4
int getIntLimited(int lowerLimit, int upperLimit);
This function uses getInt() to receive a valid integer and returns it. This function makes
sure the integer entered is within the limits required (between lowerLimit and
upperLimit inclusive). If the integer is not within the limits, it will print:
> "Invalid value, TheLowerLimmit < value < TheUpperLimit: " <
and try again. (Change the lower and upper limit with their values.)
This function is fool-proof too; the function will not let the user pass until a valid integer
is received within the lower and upper limit values. See below:

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
5
double getDbl(void);
Works exactly like getInt() but scans a double instead of an integer with the following
error message:
"Invalid number, please try again: "
double getDblLimited(double lowerLimit, double upperLimit);
Works exactly like getIntLimited() but scans a double instead of an integer.
Document Page
6
OUTPUT SAMPLE:
(UNDERLINED, ITALIC BOLD RED VALUES ARE USER ENTRIES)
---=== Grocery Inventory System ===---
listing header and footer with grand total:
Row |SKU| Name | Price |Taxed| Qty | Min | Total |Atn
----+---+--------------------+--------+-----+-----+-----+------------|---
--------------------------------------------------------+----------------
Grand Total: | 1234.57
listing header and footer without grand total:
Row |SKU| Name | Price |Taxed| Qty | Min | Total |Atn
----+---+--------------------+--------+-----+-----+-----+------------|---
--------------------------------------------------------+----------------
Press <ENTER> to continue... <ENTER>
Enter an integer: abc
Invalid integer, please try again: 10abc
Invalid integer, please try again: 10
You entered: 10
Enter an integer between 10 and 20: 9
Invalid value, 10 < value < 20: 21
Invalid value, 10 < value < 20: 15
Your entered 15
Enter a floating point number: abc
Invalid number, please try again: 2.3abc
Invalid number, please try again: 2.3
You entered: 2.30
Enter a floating point number between 10.00 and 20.00: 9.99
Invalid value, 10.000000< value < 20.000000: 20.1
Invalid value, 10.000000< value < 20.000000: 15.05
You entered: 15.05
End of tester program for milestone one!
MS1 SUBMISSION:
To test and demonstrate execution of milestone 1, use the same data as the output example
above.
If not on matrix already, upload your ipc_ms1.c to your matrix account. Compile and run your
code and make sure everything works properly.
Before submission comment out your main function (the tester) in ipc_ms1.c. (Only the 9
functions you implemented are needed for the submission)
Then run the following script from your account: (replace profname.proflastname with your
professors’s Seneca userid)
~profname.proflastname/submit ipc_ms1 <ENTER>
and follow the instructions.
Document Page
7
MILESTONE 2: THE APPLICATION USER INTERFACE (DUE SAT 5TH)
Download or Clone milestone 2 from https://github.com/Seneca-144100/IPC_MS2 and copy
the functions in milestone 1 into ipc_ms2.c.
Now that the user interface tools are created and tested, we are going to build the main
skeleton of our application. This application will be a menu driven program and will work as
follows:
1- When the program starts the title of the application is displayed.
2- Then a menu is displayed.
3- The user selects one of the options on the Menu.
4- Depending on the selection, the corresponding action will take place.
5- The Application will pause to attract the user’s attention
6- If the option selected is not Exit program, then the program will go back to option 2
7- If the option selected is Exit program, the program ends.
The above is essentially the pseudo code for any program that uses a menu driven user
interface.
To accomplish the above create the following three functions:
int yes(void)
Receives a single character from the user and then clears the keyboard (clrKyb()). If
the character read is anything other than “Y”, “y”, “N” or “n”, it will print an error
message as follows:
>Only (Y)es or (N)o are acceptable: <
and goes back to read a character until one of the above four characters is received.
Then, it will return 1 if the entered character is either “y” or “Y”, otherwise it will return
0.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
8
Document Page
9
int menu(void)
Menu prints the following options:><
>1- List all items<
>2- Search by SKU<
>3- Checkout an item<
>4- Stock an item<
>5- Add new item or update item<
>6- delete item<
>7- Search by name<
>0- Exit program<
>> <
Then, it receives an integer between 0 and 7 inclusive and returns it. Menu will not accept any
number less than 0 or greater than 7 (Use the proper UI function written in milestone 1).
void GrocInvSys(void)
This function is the heart of your application and runs the whole program.
GrocInvSys, first, displays the welcome message and skips a line and then displays the menu
and receives the user’s selection.
If user selects 1, it displays:
>List Items!< and goes to newline
If user selects 2, it displays:
>Search Items!< and goes to newline
If user selects 3, it displays:
>Checkout Item!< and goes to newline
If user selects 4, it displays:
>Stock Item!< and goes to newline
If user selects 5, it displays:
>Add/Update Item!< and goes to newline
If user selects 6, it displays:
>Delete Item!< and goes to newline
If user selects 7, it displays:
>Search by name!< and goes to newline
Document Page
10
After receiving a number between 1 and 7, it will pause the application and goes back to display
the menu.
If user selects 0, it displays:
>Exit the program? (Y)es/(N)o): <
and waits for the user to enter “Y”, ”y”, “N” or “n” for Yes or No.
If the user replies Yes, it will end the program, otherwise it goes back to display the menu.

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
11
Document Page
12
OUTPUT SAMPLE:
(UNDERLINED, ITALIC BOLD RED VALUES ARE USER ENTRIES)
---=== Grocery Inventory System ===---
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program
> 8
Invalid value, 0 < value < 7: 1
List Items!
Press <ENTER> to continue...
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program
> 2
Search Items!
Press <ENTER> to continue...
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program
> 3
Checkout Item!
Press <ENTER> to continue...
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program
> 4
Stock Item!
Press <ENTER> to continue...
1- List all items
Document Page
13
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program
> 5
Add/Update Item!
Press <ENTER> to continue...
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program
> 6
Delete Item!
Press <ENTER> to continue...
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program
> 7
Search by name!
Press <ENTER> to continue...
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program
> 0
Exit the program? (Y)es/(N)o : x
Only (Y)es or (N)o are acceptable: n
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
6- delete item
7- Search by name
0- Exit program

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
14
> 0
Exit the program? (Y)es/(N)o : y
MS2 SUBMISSION:
To test and demonstrate execution of milestone 2, use the same data as the output example
above.
If not on matrix already, upload your ipc_ms2.c to your matrix account. Compile and run your
code and make sure everything works properly.
Before submission, comment out your main function (the tester) in ipc_ms2.c. (Only the 3
functions you implemented are needed for the submission)
Then run the following script from your account: (replace profname.proflastname with your
professors’s Seneca userid)
~profname.proflastname/submit ipc_ms2 <ENTER>
and follow the instructions.
MILESTONE 3: THE ITEM IO (DUE TUE NOV 15TH)
Download or Clone milestone 3 from https://github.com/Seneca-144100/IPC_MS3 and copy
the functions in milestone 1 and the yes() function from milestone 2 into ipc_ms3.c.
Define the following values in ipc_ms3.c: (using #define)
LINEAR to be 1
FORM to be 0
STOCK to be 1
CHECKOUT to be 0
Also create a global constant double variable called TAX that is initialized to 0.13.
Continue the development of your project by implementing the following Item related
functions:
Item related information is kept in the following structure (do not modify this):
structure:
struct Item {
double price;
int sku;
int isTaxed;
int quantity;
int minQuantity;
Document Page
15
char name[21];
};
price: price of a unit of the item
sku: Stock Keeping Unit, a 3 digit integer
isTaxed: an integer Flag, if true (non-zero), the tax is applied in price calculations. The value of
Tax is kept in the global constant double TAX variable.
quantity: the quantity of the time in the inventory.
minQuantity: the minimum quantity number in inventory; any inventory quantity value less
than this will cause a warning to order more of this item later in development.
name: a 20 character, C string (i.e a 21 character NULL terminated array of characters) to keep
the name of the item.
Implement the following Item related functions:
double totalAfterTax(struct Item item);
This function receives an Item and calculates and returns the total inventory price of the
item by multiplying the price by the quantity of the item and adding TAX if applicable (if
isTaxed is true).
int isLowQty(struct Item item);
This function receives an Item and returns true (1) if the Item quantity is less than Item
minimum quantity and false (0) otherwise.
struct Item itemEntry(int sku);
This function receives an integer argument for sku and creates an Item and sets its sku to the
sku argument value.
Then it will prompt the user for all the values of the Item (except the sku that is already set) in
the following order:
Name, Price, Quantity, Minimum Quantity and Is Taxed.
To get the name from the user, use the this format specifier in scanf: "%20[^\n]" and then
clear the keyboard using clrKyb() function.
This format specifier tells to scanf to read up to 20 characters from the keyboard and stop if “\n” (ENTER
KEY) is entered. After this clrKyb() gets rid of the “\n” left in the keyboard.
Use the data entry functions you created in milestone 1 to get the rest of the values. (for Is
Taxed, use the yes() function in milestone 2).
Here is the format of the data Entry: (Underlined Italic Bold Red values are user entries)
> SKU: 999<
> Name: Red Apples<
> Price: 4.54<
> Quantity: 50<
>Minimum Qty: 5<
> Is Taxed: n<
Document Page
16
void dspItem(struct Item item,int linear);
This function receives two arguments: an Item and an integer flag called linear.
This function prints an Item on screen in two different formats depending on the value of
“linear” flag being true or false.
If linear is true it will print the Item values in a line as with following format:
1- bar char “|”
2- sku: integer, in 3 spaces
3- bar char “|”
4- name: left justified string in 20 characters space
5- bar char “|”
6- price: double with 2 digits after the decimal point in 8 spaces
7- bar char and two spaces “| ”
8- taxed: Yes or No in 3 spaces
9- bar char and one space “| ”
10- quantity: integer in 3 spaces
11- space, bar char and space“ | ”
12- minimum quantity: integer in 3 spaces
13- space and bar char “ |”
14- Total price: double with 2 digits after the decimal point in 12 spaces
15- bar char “|”
16- if the quantity is low then three asterisks (“***”) or nothing otherwise<>
Example:
>|999|Red Apples | 4.54| No| 50 | 5 | 227.00|<
If low value and Taxed:
>|999|Red Apples | 4.54| Yes| 2 | 5 | 10.26|***<
If linear is false (or in FORM format) then the values are printed as follows:
> SKU: 999<
> Name: Red Apples<
> Price: 4.54< Two digits after the decimal point
> Quantity: 50<
>Minimum Qty: 5<
> Is Taxed: No<
If low value and Taxed:
> SKU: 999<
> Name: Red Apples<
> Price: 4.54<
> Quantity: 2<
>Minimum Qty: 5<
> Is Taxed: Yes<
>WARNING: Quantity low, please order ASAP!!!<

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
17
void listItems(const struct Item item[], int NoOfItems);
This function receives a constant array of Items and their number and prints the items in
list with the grand total price at the end.
Create an integer for the loop counter and a double grand total variable that is
initialized to zero.
First print the Titles of the list using prnTitle() function.
Then it will loop through the items up to NoOfItems.
In each loop:
Print the row number (loop counter plus one), left justified in four spaces and
then display the item in LINEAR format. Then add the total price of the current
Item element in the array to the grand total value.
After loop is done print the footer by passing the grand total to it. (use prnFooter()
function).
int locateItem(const struct Item item[], int NoOfRecs, int sku, int*
index);
This function receives a constant array of Items and their number. Also an SKU to look
for in the Item array. The last argument is a pointer to an index. The target of this index
pointer will be set to the index of the Item-element in which the sku is found, otherwise
no action will be taken on index pointer.
If an Item with the SKU number as the sku argument is found, after setting the target of
the index pointer to the index of the found item, a true value (non-zero, preferably 1)
will be returned, otherwise a false value (0) will be returned.
MS3 SUBMISSION:
To test and demonstrate execution of milestone 3, use the main() function provided in
ipc_ms3.c.
If not on matrix already, upload your ipc_ms3.c to your matrix account. Compile and run your
code and make sure everything works properly.
Before submission, comment out the main() function in ipc_ms3.c. (Only the functions you
implemented are needed for the submission)
Then run the following script from your account: (replace profname.proflastname with your
professors’s Seneca userid)
~profname.proflastname/submit ipc_ms3 <ENTER>
Document Page
18
and follow the instructions.
MILESTONE 4:
ITEM STORAGE AND RETRIEVAL IN AN ARRAY
(DUE NOV 23ND 23:59)
Before starting this milestone please correct your error messages for getIntLimited and
getDblLimitted functions respectively:
>Invalid value, %d <= value <= %d: <
>Invalid value, %lf <= value <= %lf: <
Download or clone milestone 4 from https://github.com/Seneca-144100/IPC_MS4 and copy all
your work (except the main function) from milestone 3 into ipc_ms4.c.
The tester program for this milestone is written in 5 separate units (functions).
Implement the functions of this milestone in the same order mentioned here. To test your
implementation of each function, uncomment the corresponding tester in the main() function
and compile.
For example if you are writing the addItem() function, your main() will look like this:
int main() {
//searchTest();
//updateTest();
addTest();
//addUpdateTest();
//adjustQtyTest();
return 0;
}
When you are done with testing all the functions, you can uncomment everything for a
complete test of your milestone 4.
MILESTONE 4:
Add the following definitions to your program:
MAX_ITEM_NO 21
MAX_QTY 999
SKU_MAX 999
SKU_MIN 100
In this milestone, you are implementing 5 functions that work with an array of Items:
void search(const struct Item item[], int NoOfRecs);
Document Page
19
The search function receives an array of items and its size and searches through the array for an
Item with a specific sku that is received from the user. If found, it will display the item in FORM
format, otherwise it will print an error message.
DETAILS
Prompt:
>Please enter the SKU: <
then receive an integer between SKU_MIN and SKU_MAX.
Call the locateItem() function and see if the item is found.
If found, display the item , otherwise print:
>Item not found!< and go to new line.
void updateItem(struct Item* itemptr);
updateitem, modifies the fields of an Item. The function receives the address of the Item to
update (itemptr).
DETAILS
Create an instance of struct Item.
Prompt:
>Enter new data:< and go to new line.
Use the itemEntry() function and the SKU of the Item pointed by itemptr to receive an Item
and save it in the Item instance you just created.
Then ask the user to confirm the update by printing:
>Overwrite old data? (Y)es/(N)o: <
If user responds yes, overwrite the target of itemptr by the Item instance and print:
>--== Updated! ==--< and go to new line
Otherwise print:
>--== Aborted! ==--< and go to new line
void addItem(struct Item item[], int *NoOfRecs, int sku);
If the item array is not full, this function will ask the user to enter the data for an Item (with the
SKU received through the argument list) and if the user confirms, it will add it to the array and
add one to the target of NoOfRecs pointer.
DETAILS
Create an Item.
Check:
If the target of NoOfRecs is equal to MAX_ITEM_NO, print:
>Can not add new item; Storage Full!<
and exit the function.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
20
Otherwise, using the itemEntry() function get the details of the new Item with the SKU from the
argument list and Prompt:
>Add Item? (Y)es/(N)o: <
If the user replies yes, set the Item after the last one in the item array to the one you just got
from the user and add one to the target of NoOfRecs pointer and print:
>--== Added! ==--< and go to new line and exit the function.
If the user replies no, print:
>--== Aborted! ==--< and go to new line and exit the function.
void addOrUpdateItem(struct Item item[], int* NoOfRecs);
addOrUpdateItem function, receives an SKU from the user and updates or adds an Item in an
array of Items depending on the SKU being present in an item in the array or not.
DETAILS
Prompt:
>Please enter the SKU: <
Receive an integer within the limits of a valid SKU number; between SKU_MIN and
SKU_MAX. Try locating the item in the item array.
If found:
Display the item in FORM format and confirm that the user wants to update it by
prompting:
>Item already exists, Update? (Y)es/(N)o: <
If the user replies yes, call the updateItem() function with the found Item in the
array, otherwise print:
>--== Aborted! ==--< and go to new line and exit the function.
Otherwise (not found):
Call the addItem() function to add the item with the entered SKU at the end of the data
in the array. Then exit the function.
void adjustQty(struct Item item[], int NoOfRecs, int stock);
Depending on the value of the stock argument being STOCK or CHECKOUT, this function
will increase or reduce the quantity of the selected Item in the array by the value received from
the user.
If stocking, (adding to storage) this value can vary between 0 to (MAX_QTY – item_quantity)
and if checking out (removing from storage) this value can vary between 0 to item_quantity.
DETAILS
Prompt:
>Please enter the SKU: <
Get a valid SKU value from the user and try locating the item with the same SKU in the item
array.
Document Page
21
If not found, print:
>SKU not found in storage!< and go to new line and exit the function.
If found, display the item in FORM format and print this message:
>Please enter the quantity %s; Maximum of %d or 0 to abort: <
If the value of stock argument is STOCK then:
%s should be replaced by >to stock< and %d should be replaced by the maximum number of
items that can be stocked without exceeding the MAX_QTY value, which is the MAX_QTY value
minus the quantity of the item in stock.
If the value of stock argument is CHECKOUT then:
%s should be replaced by >to checkout< and %d should be replaced by the quantity of the
item in stock.
Then check the value entered by the user, which must be between 0 and the quantity displayed
in the preceding message.
If the number input is zero (0), then print >--== Aborted! ==--<, go to a new line and exit the
function.
If the number input is not zero(0):
If the value of stock argument is STOCK then:
Increase the quantity of the item in the array by the amount received from the
user and print: >--== Stocked! ==--< and go to new line.
If the value of stock argument is CHECKOUT then:
Reduce the quantity of the item in the array by the amount received from the
user and print: >--== Checked out! ==-- < and go to new line.
When finished processing, if the quantity of the item is low (less than the re-order point), print
the following warning:
>Quantity is low, please reorder ASAP!!!< and go to a new line.
TESTER OUTPUT SAMPLES:
(UNDERLINED, ITALIC BOLD RED VALUES ARE USER ENTRIES)
SEARCH TEST:
================Search Test:
Enter 731:
Please enter the SKU: 731
SKU: 731
Name: Allen's Apple Juice
Document Page
22
Price: 1.79
Quantity: 100
Minimum Qty: 10
Is Taxed: Yes
Enter 222:
Please enter the SKU: 222
Item not found!
UPDATE TEST:
================Update Test:
Enter the follwoing:
SKU: 111
Name: Grape
Price : 22.22
Quantity : 22
Minimum Qty : 2
Is Taxed : y
Overwrite old data? (Y)es/(N)o: n
Enter new data:
SKU: 111
Name: Grape
Price: 22.22
Quantity: 22
Minimum Qty: 2
Is Taxed: y
Overwrite old data? (Y)es/(N)o: n
--== Aborted! ==--
Unchanged Item Data:
SKU: 111
Name: Ones!
Price: 11.11
Quantity: 11
Minimum Qty: 1
Is Taxed: Yes
Enter the follwoing:
SKU: 111
Name: Grape
Price : 22.22
Quantity : 22
Minimum Qty : 2
Is Taxed : y
Overwrite old data? (Y)es/(N)o: y

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
23
Enter new data:
SKU: 111
Name: Grape
Price: 22.22
Quantity: 22
Minimum Qty: 2
Is Taxed: y
Overwrite old data? (Y)es/(N)o: y
--== Updated! ==--
Updated Item:
SKU: 111
Name: Grape
Price: 22.22
Quantity: 22
Minimum Qty: 2
Is Taxed: Yes
ADD TEST:
================Add Test:
Total items in Storage: 20, Max no: 21
Enter the follwoing:
SKU: 222
Name: Grape
Price : 22.22
Quantity : 22
Minimum Qty : 2
Is Taxed : y
Add Item? (Y)es/(N)o: n
SKU: 222
Name: Grape
Price: 22.22
Quantity: 22
Minimum Qty: 2
Is Taxed: y
Add Item? (Y)es/(N)o: n
--== Aborted! ==--
Garbage here! Nothing is added, No of items in storage: 20
SKU: 0
Name:
Price: 0.00
Quantity: 0
Minimum Qty: 0
Is Taxed: No
Document Page
24
WARNING: Quantity low, please order ASAP!!!
Enter the follwoing:
SKU: 222
Name: Grape
Price : 22.22
Quantity : 22
Minimum Qty : 2
Is Taxed : y
Add Item? (Y)es/(N)o: y
SKU: 222
Name: Grape
Price: 22.22
Quantity: 22
Minimum Qty: 2
Is Taxed: y
Add Item? (Y)es/(N)o: y
--== Added! ==--
New item is added, No of itemsinstorage: 21
SKU: 222
Name: Grape
Price: 22.22
Quantity: 22
Minimum Qty: 2
Is Taxed: Yes
Adding 333:
Can not add new item; Storage Full!
ADD OR UPDATE TEST:
================AddOrUpdate Test:
Enter 731 and then 'n':
Please enter the SKU: 731
SKU: 731
Name: Allen's Apple Juice
Price: 1.79
Quantity: 100
Minimum Qty: 10
Is Taxed: Yes
Item already exists, Update? (Y)es/(N)o: n
--== Aborted! ==--
Enter 731, 'y' and then:
Name: Apple
Price: 1.80
Quantity: 101
Document Page
25
Minimum Qty: 11
Is Taxed: n
Overwrite old data? (Y)es/(N)o: y
Please enter the SKU: 731
SKU: 731
Name: Allen's Apple Juice
Price: 1.79
Quantity: 100
Minimum Qty: 10
Is Taxed: Yes
Item already exists, Update? (Y)es/(N)o: y
Enter new data:
SKU: 731
Name: Apple
Price: 1.80
Quantity: 101
Minimum Qty: 11
Is Taxed: n
Overwrite old data? (Y)es/(N)o: y
--== Updated! ==--
Updated Item:
SKU: 731
Name: Apple
Price: 1.80
Quantity: 101
Minimum Qty: 11
Is Taxed: No
Enter 444:
Please enter the SKU: 444
Can not add new item; Storage Full!
ADJUST QUANTITY TEST:
================AdjustQty Test:
Invalid SKU Test; Enter 444:
Please enter the SKU: 444
SKU not found in storage!
Aborting Entry test; Enter 731 and then 0:
Please enter the SKU: 731
SKU: 731
Name: Allen's Apple Juice
Price: 1.79
Quantity: 100
Minimum Qty: 10
Is Taxed: Yes

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
26
Please enter the quantity to checkout; Maximum of 100 or 0 to
abort: 0
--== Aborted! ==--
Checking out with low quantity warning; Enter 731 and then 90:
Please enter the SKU: 731
SKU: 731
Name: Allen's Apple Juice
Price: 1.79
Quantity: 100
Minimum Qty: 10
Is Taxed: Yes
Please enter the quantity to checkout; Maximum of 100 or 0 to
abort: 90
--== Checked out! ==--
Quantity is low, please reorder ASAP!!!
Stocking; Enter 731 and then 50:
Please enter the SKU: 731
SKU: 731
Name: Allen's Apple Juice
Price: 1.79
Quantity: 10
Minimum Qty: 10
Is Taxed: Yes
WARNING: Quantity low, please order ASAP!!!
Please enter the quantity to stock; Maximum of 989 or 0 to
abort: 50
--== Stocked! ==--
SKU: 731
Name: Allen's Apple Juice
Price: 1.79
Quantity: 60
Minimum Qty: 10
Is Taxed: Yes
MS4 SUBMISSION:
To test and demonstrate execution of milestone 4, use the tester functions provided in
ipc_ms4.c.
If not on matrix already, upload your ipc_ms4.c to your matrix account. Compile and run your
code and make sure everything works properly.
Before submission, comment out the main() function and all the tester functions in ipc_ms4.c.
(Only the functions you implemented are needed for the submission)
Document Page
27
Then run the following script from your account: (replace profname.proflastname with your
professors’s Seneca userid)
~profname.proflastname/submit ipc_ms4 <ENTER>
and follow the instructions.
MILESTONE 5:
FILE IO AND FINAL ASSEMBLY
(DUE NOV 29TH 23:59)
Download or clone milestone 5 from https://github.com/Seneca-144100/IPC_MS5 and copy all
your work (all the functions done in past milestones) into ipc_ms5.c.
Define the following:
MAX_ITEM_NO to 500
DATAFILE to "items.txt"
There are two main() functions in ipc_ms5.c; one is to test the 4 functions implemented in this
milestone and the other one is to run the main application. You must comment out one of them
to use the other one.
ADJUSTMENTS TO ITEMENTRY FUNCTION:
Modify your struct Item itemEntry(int sku) and use getLimitedInt() and getLimitedDbl() to
limit the following entries:
> SKU: 999<
> Name: Red Apples<
> Price: 4.54< Limited between 0.01 and 1000.00 inclusive
> Quantity: 50< Limited between 1 and MAX_QTY inclusive
>Minimum Qty: 5< Limited between 0 and 100 inclusive
> Is Taxed: n<
MILESTONE 5, FILE IO:
Implement the following four functions:
void saveItem(struct Item item, FILE* dataFile);
This function writes the content of an Item, comma separated, in one
line of a text file pointed by “datafile” argument in the following
format:
sku,quantity,minQuantity,price,isTaxed,name<NEWLINE>
All the above variables are written with no special formatting except for the
price that is written with 2 digits after the decimal point.
Document Page
28
Assume that the dataFile pointer is already open and ready to be
written into.
int loadItem(struct Item* item, FILE* dataFile);
This function reads all the fields of an Item from one line of a comma
separated text file using fscanf and stores them in the Item structure
that is pointed by the “item” pointer in the argument list. The format
in which the values are read is the same as the saveItem function.
Note that the name field may contain spaces.
Assume that the dataFile FILE pointer is already open and ready to be
read from.
The function returns true if fscanf reads the six items successfully.
int saveItems(struct Item* item, char fileName[], int NoOfRecs);
saveItems uses the saveItem function to write an entire array of Items
into a file.
saveItems receives a pointer to an array of Items and the number of
records in that array (NoOfRecs) and also the name of the file in
which these items should be saved into.
saveItems opens a FILE using the filename received from the argument
list for writing (overwrites the old file if it already exists).
If the file is not opened successfully, it ends the function and
returns zero.
If the file is opened successfully, it goes through all the elements
of the array, “item”, up to the “NoOfRecs” and saves them one by one
using the saveItem function.
Then, it closes the FILE and exits the function returning one (true).
int loadItems(struct Item* item, char fileName[], int* NoOfRecsPtr);
loadItems uses the loadItem function to read all the records saved in
a file into the “item” array and sets the target of the “NoOfRecsPtr”
to the number of Items read from the file.
loadItems receives a pointer to an array of Items and another pointer
pointing to the number of records read from the file (NoOfRecsPtr) and
also the name of the file in which these items are stored in.
loadItems opens a FILE using the filename received from the argument
list for reading.

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
29
If the file is not opened successfully, it ends the function and
returns zero.
If the file is opened successfully, using loadItem it reads the
records from the file until loadItem fails, counting the number of
Items read at the same time.
Then it sets the target of NoOfRecsPtr pointer to the number of Items
read.
Finally, it closes the FILE and exits the function returning one
(true).
MILESTONE 5, FILE IO TESTER:
To test the FILE IO functions, uncomment the main() function in TESTER
section of ipc_ms5.c file and comment the other main function and run
the program.
You should have the following output:
***********Testing saveItem:
Your saveItem saved the following in test.txt:
275,10,2,4.40,0,Royal Gala Apples
386,20,4,5.99,0,Honeydew Melon
240,30,5,3.99,0,Blueberries
*******************************
They have to match the following:
275,10,2,4.40,0,Royal Gala Apples
386,20,4,5.99,0,Honeydew Melon
240,30,5,3.99,0,Blueberries
***********END Testing saveItem!
Press <ENTER> to continue...
***********Testing loadItem:
Your loadItem loaded the following from test.txt:
|275|Royal Gala Apples | 4.40| No| 10 | 2 | 44.00|
|386|Honeydew Melon | 5.99| No| 20 | 4 | 119.80|
|240|Blueberries | 3.99| No| 30 | 5 | 119.70|
*******************************
They have to match the following:
|275|Royal Gala Apples | 4.40| No| 10 | 2 | 44.00|
|386|Honeydew Melon | 5.99| No| 20 | 4 | 119.80|
|240|Blueberries | 3.99| No| 30 | 5 | 119.70|
***********END Testing loadItem!
Press <ENTER> to continue...
***********Testing saveItems:
Your saveItems saved the following in test.txt:
275,10,2,4.40,0,Royal Gala Apples
386,20,4,5.99,0,Honeydew Melon
240,30,5,3.99,0,Blueberries
*******************************
They have to match the following:
Document Page
30
275,10,2,4.40,0,Royal Gala Apples
386,20,4,5.99,0,Honeydew Melon
240,30,5,3.99,0,Blueberries
***********END Testing saveItems!
Press <ENTER> to continue...
***********Testing loadItems:
Your loadItems loaded the following from test.txt:
|275|Royal Gala Apples | 4.40| No| 10 | 2 | 44.00|
|386|Honeydew Melon | 5.99| No| 20 | 4 | 119.80|
|240|Blueberries | 3.99| No| 30 | 5 | 119.70|
*******************************
They have to match the following:
|275|Royal Gala Apples | 4.40| No| 10 | 2 | 44.00|
|386|Honeydew Melon | 5.99| No| 20 | 4 | 119.80|
|240|Blueberries | 3.99| No| 30 | 5 | 119.70|
***********END Testing loadItems!
Press <ENTER> to continue...
Done!
MILESTONE 5, FINAL ASSEMBLY:
After the implementation of the four FILE IO functions is complete,
comment out the main() function in the TESTER section for the FILE IO
and uncomment the other main();
In your void GrocInvSys(void) function, done in Milestone 2, do the
following:
- Create an array of Items. Use MAX_ITEM_NO for its size.
- Create an integer variable to Hold the number of records read.
- After the welcome() message use the loadItems() function to fill
the Items array you created with the Item records kept in a the
data file. The name of the data file is defined in DATAFILE.
- If the loadItems fails, print the following message and exit the
program:
"Could not read from %s.\n", replace %s with defined value in
DATAFILE.
- If loadItems is successful, run the menu section and action
selection:
o If 1 is selected:
Call the listItems() function passing the item array and
the number of records read.
o If 2 is selected:
Call the search() function passing the item array and the
number of records read.
o If 3 is selected:
Call the adjustQty() function passing the item array, the
Document Page
31
number of records and CHECKOUT.
Then, call the saveItems() function passing the item array,
DATAFILE, and the number of records read to apply the
changes to the DATAFILE.
If saveITems() fails, print the following message:
"could not update data file %s\n" replacing %s with DATAFILE.
o If 4 is selected:
Do exactly what you have done in option 3 but pass STOCK to
adjustQty instead of CHECKOUT.
o If 5 is selected:
Call the addOrUpdateItem() function passing the item array
and the address of the number of records read.
Then call the saveItems() function passing the item array,
DATAFILE, and the number of records read to apply the
changes to the DATAFILE.
If saveITems() fails, print the following message:
"could not update data file %s\n" replacing %s with DATAFILE.
Note: as you see the save procedures in options 3,4
and 5 are identical. You could create a function and
call it to prevent redundancy.
o If 6 or 7 is selected:
Print: "Not implemented!\n" and pause();
o Option 0 remains the same.
MS5 SUBMISSION:
You have 3 choices for submitting your milestone 5:
1- Short
You can select this one if you already successfully submitted milestones 1 to 4
2- Long
You can select this one if you have not submitted the past 4 milestones and want to
only submit milestone 5. Your program must work exactly as described in past 4
milestones.
3- Open
This submission does not test the output of your application but captures and
submits it to your professor.
You can select this one if you believe your project works properly but you could not
match the exact output requested in either Short or Long submissions.
YOU are responsible to do all the tests asked in either Short or Long submission. If
you miss any steps of those tests your submission may be rejected and you have to
re-submit your application and you will lose mark for resubmission and not being
ontime.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
32
(V1.1) Also you must add a text file called “comments.txt” to your submission that
contains explanation on why you have chosen the open submission rather than one
of the other two.
SUBMISSIONS:
To test and demonstrate the execution of milestone 5, upload your ipc_ms5.c to your matrix
account. Compile and run your code and make sure everything works properly.
Before submission, comment out the tester functions and un-comment the main().
SHORT SUBMISSION:
Modify your datafile definition to the following:
#define DATAFILE "ipc_ms5_short.txt" (V1.1)
Then run the following script from your account: (replace profname.proflastname with your
professors’s Seneca userid)
~profname.proflastname/submit ipc_ms5_short <ENTER>
And test your application using the RED underlined bold italic values below:
---=== Grocery Inventory System ===---
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 1
Row |SKU| Name | Price |Taxed| Qty | Min | Total |Atn
----+---+--------------------+--------+-----+-----+-----+------------|---
1 |275|Royal Gala Apples | 4.40| No| 10 | 2 | 44.00|
2 |386|Honeydew Melon | 5.99| No| 20 | 4 | 119.80|
3 |240|Blueberries | 3.99| No| 5 | 10 | 19.95|***
--------------------------------------------------------+----------------
Grand Total: | 183.75
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 2
Document Page
33
Please enter the SKU: 888
Item not found!
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 3
Please enter the SKU: 275
SKU: 275
Name: Royal Gala Apples
Price: 4.40
Quantity: 10
Minimum Qty: 2
Is Taxed: No
Please enter the quantity to checkout; Maximum of 10 or 0 to abort: 0
--== Aborted! ==--
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 4
Please enter the SKU: 275
SKU: 275
Name: Royal Gala Apples
Price: 4.40
Quantity: 10
Minimum Qty: 2
Is Taxed: No
Please enter the quantity to stock; Maximum of 989 or 0 to abort: 0
--== Aborted! ==--
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 5
Please enter the SKU: 240
SKU: 240
Name: Blueberries
Price: 3.99
Quantity: 5
Minimum Qty: 10
Is Taxed: No
WARNING: Quantity low, please order ASAP!!!
Item already exists, Update? (Y)es/(N)o: n
--== Aborted! ==--
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
Document Page
34
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 5
Please enter the SKU: 888
SKU: 888
Name: x
Price: 1
Quantity: 1
Minimum Qty: 1
Is Taxed: y
Add Item? (Y)es/(N)o: y
--== Added! ==--
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 1
Row |SKU| Name | Price |Taxed| Qty | Min | Total |Atn
----+---+--------------------+--------+-----+-----+-----+------------|---
1 |275|Royal Gala Apples | 4.40| No| 10 | 2 | 44.00|
2 |386|Honeydew Melon | 5.99| No| 20 | 4 | 119.80|
3 |240|Blueberries | 3.99| No| 5 | 10 | 19.95|***
4 |888|x | 1.00| Yes| 1 | 1 | 1.13|***
--------------------------------------------------------+----------------
Grand Total: | 184.88
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 0
Exit the program? (Y)es/(N)o): y
LONG SUBMISSION:
Modify your datafile definition to the following:
#define DATAFILE "ipc_ms5_long.txt" (V1.1)
Then run the following script from your account: (replace profname.proflastname with your
professors’s Seneca userid)
~profname.proflastname/submit ipc_ms5_long <ENTER>
And test your application using the RED underlined bold italic values below:

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
35
---=== Grocery Inventory System ===---
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 6
Invalid value, 0 <= value <= 5: -1
Invalid value, 0 <= value <= 5: 1
Row |SKU| Name | Price |Taxed| Qty | Min | Total |Atn
----+---+--------------------+--------+-----+-----+-----+------------|---
1 |275|Royal Gala Apples | 4.40| No| 10 | 2 | 44.00|
2 |386|Honeydew Melon | 5.99| No| 20 | 4 | 119.80|
3 |240|Blueberries | 3.99| No| 30 | 5 | 119.70|
4 |916|Seedless Grapes | 10.56| No| 20 | 3 | 211.20|
5 |385|Pomegranate | 2.50| No| 5 | 2 | 12.50|
6 |495|Banana | 0.44| No| 100 | 30 | 44.00|
7 |316|Kiwifruit | 0.50| No| 123 | 10 | 61.50|
8 |355|Chicken Alfredo | 4.49| Yes| 20 | 5 | 101.47|
9 |846|Veal Parmigiana | 5.49| Yes| 3 | 5 | 18.61|***
10 |359|Beffsteak Pie | 5.29| Yes| 40 | 5 | 239.11|
11 |127|Curry Checken | 4.79| Yes| 30 | 3 | 162.38|
12 |238|Tide Detergent | 16.99| Yes| 10 | 2 | 191.99|
13 |538|Lays Chips S&V | 3.69| Yes| 1 | 5 | 4.17|***
14 |649|Joe Org Chips | 3.29| Yes| 15 | 5 | 55.77|
15 |731|Jack's Apple Juice | 1.50| Yes| 80 | 10 | 135.60|
16 |984|Coke 12 Pack | 6.69| Yes| 30 | 3 | 226.79|
17 |350|Nestea 12 Pack | 7.29| Yes| 50 | 5 | 411.88|
18 |835|7up 12 pack | 6.49| Yes| 20 | 2 | 146.67|
19 |222|Peaches | 1.44| No| 14 | 20 | 20.16|***
--------------------------------------------------------+----------------
Grand Total: | 2327.31
Press <ENTER> to continue...<ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 2
Please enter the SKU: 888
Item not found!
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 2
Please enter the SKU: 222
SKU: 222
Name: Peaches
Price: 1.44
Quantity: 14
Document Page
36
Minimum Qty: 20
Is Taxed: No
WARNING: Quantity low, please order ASAP!!!
Press <ENTER> to continue... <ENTER>
1- List all items
2- Search by SKU
3- Checkout an item
4- Stock an item
5- Add new item or update item
0- Exit program
> 2
Please enter the SKU: 835
SKU: 835
Name: 7up