Computer Science IA
Computer Science IA
Rayon Pusey
Danieto Murray
Alicia Dixion
Jaiden Fryes
Kayanna Robinson
Subject: Computer Science
Territory: Jamaica
Table of Contents
Problem Definition.................................................................................................................3
Narrative................................................................................................................................4-7
User Manual...........................................................................................................................10-11
System Architecture...............................................................................................................14
Pseudocode............................................................................................................................13-31
Test Plan.................................................................................................................................32 - 34
Test Results............................................................................................................................38 - 38
Page | 2
Problem Definition
Background:
A neighborhood stand called Jeremy's Nut Stall specialized in selling nuts of all kinds,
including peanuts, almonds, and cashews, to mention a few. Customers have the option of
purchasing the assortment of nuts either by weight (per pound) or at a set fee. It is a family-
owned company that was started by Jeremy Davidson, the owner, two years ago. He makes it his
mission to serve his customers fresh produce every day when he is at his stand. When running
the stall became a little too much for him to handle alone, he hired two employees a year ago.
Jeremy's Nut Stall is situated directly behind the Juici Beef on 3 Manchester Road.
The business owners are currently using a manual database, due to their lack of
technological knowledge. Their system consists of different tools, such as pen and paper to help
record customer purchases, product prices and the business's finances. They have been using this
system for quite a while but as their business grows, so do the products in their inventory and the
number of customers that visit the business to buy their products. Due to this, the owners have
decided to upgrade their system to one that's more technological thus making it easier to keep
track of products in their inventory there: price, amount, weight etc. and purchases made by
customers, also allowing for simpler calculation of funds and the ability to give receipts for each
purchase. Thus, their reason for reaching out to us is to create a suitable solution.
The system we plan to implement offers a comprehensive solution, incorporating key
features such as a robust Product Database to maintain accurate records of nuts and their
corresponding prices and stock, streamlined Sales Entry for user-friendly transaction input,
dynamic Cost Calculation based on quantity and pricing method, Receipt Generation for detailed
transaction summaries, efficient Inventory Management to track and update stock levels, and a
User-Friendly Interface prioritizing simplicity. This system aims to optimize the overall nut store
operations, providing store staff with a seamless tool for inventory management and transaction
processing.
Page | 3
Narrative
MODULE NAME: Main
“Hello, Please Select which menu you would like to access” is printed and the user is asked to
select a number which will select a case structure. The program then accepts a number and then
stores it in a variable called menu_option if the user selects 1 (this is made for the admin users of
the program) the program checks if the file inven exists, if it does not exist, “Would you like to
create a file” is printed and the user is asked to select a number which will select a case structure.
The program then accepts a number and then stores it in a variable called menu_option if the
user selects 1 the file inventory.txt is created, "File inventory.txt created”, “How many Nuts
would like to add to the Inventory” is printed to screen, the program then accepts an integer
value from the user, that variable is then used to run a for loop to accept the Nut name, stock,
price, manufacturer and expiry date of the at nut, those inputs are then printed to the file invent.
If the user selects 2 the program returns 0; and if the user selects an option that is not there, “Not
at option” is printed and the program returns. If the file invent does exits, the screen is cleared.
And the user is asked to enter the admin password if the password is equal to “1234” , “Welcome
admin” is printed to screen and a call to the options functions is made, the user is to then select a
number which will select a case structure. The program then accepts a number and then stores it
in a variable called menau_option if the user selects 1 a call to the update_inventory function is
made and a call to the options function is made , if the user selects 2 a call to the change_prrice
function is made and a call to the options function is made, if the user selects 3 a call to the
add_nut function is made and a call to the options function is made, if the user selects 4 a call to
the delete_nut function is made and a call to the options function is made, if the user selects 5 a
call to the delete_nut function is made and a call to the options function is made, if the user
selects 6 a call to the find_order function is made and a call to the options function is made, if the
user selects 7, “goodbye” is printed and the programs returns. If the password is not equal to
“1234”, “incorrect password” is printed and the program returns.
If the user selects 2 (this menu is made for the customers) the screen is cleared and “welcome
customer” is printed to screen, the user is asked how many nuts they would like to buy, that
value is stored in the variable “temp” the program sets the variable “buy_num” to the value of
“temp”, a call to the cus_options is made, the program uses the value of buy_num to run the a for
Page | 4
loop, the user then selects a nut they would like to buy, the user is then select a number which
will select a case structure. The program then accepts a number and then stores it in a variable
called opt if the user selects 1, a call to the by_pounds function is called, if the user selects 2 a
call to the by_price function is called. After which a call to the receipt_function is made.
If the user selects 3 “goodbye” is printed to screen and the program returns.
The program opens the file “inventory.txt” in reading mode, if the file is null, “ ERROR
OPENING FILE” is printed, the programs then run a while loop to scan each line of the txt file
and saves the values into the variable in the Nuts structure. The file is the closed.
The program opens the file “inventory.txt”, the program checks is the file is null, if it is null,
“file not found” is printed and the program returns. If the file is found the program uses a while
loop to check each line in the file and increments count for each line, the file is then closed, and
count is returned.
A call to the fetch_inventory function is made, then a for loop is used to print all the options to
the user.
The file “inventory.txt is opened in writing mode, the user is then prompted to enter the nut of
they would like to change stock of, that value is then saved into the variable “i”. the user then is
prompted to enter the amount of nuts they would like to add to nut they selected, the program
saves that value in the “amount” variable,
The program then added that value to the nut they selected, and prints the updated values back to
the file, then closes the file.
Page | 5
MODULE NAME: change_price
A call is made to the fetch_inventory function, The file “inventory.txt is opened in writing mode,
the user is then prompted to enter the nut of they would like to change the price of, that value is
then saved into the variable “i”. the user then is prompted to enter the new price of the nut they
selected, the program saves that value in the “c_price” variable, The program sets the value of
the nut they selected to the accepted value and prints the updated values back to the file, then
closes the file.
The user is Prompted to enter the name of the nut, its stock, price, manufacturer, and expiry date.
The program Stores the input values in the variables “N_nut_name, N_Manufacturer, N_expiry,
n_stock, n_price”, the program then updates the nut array with the new nut entry, incrementing
the line variable to indicate the new index. The file "inventory.txt" in write mode. And the
updated value are printed back to the file, the file is then closed.
The file “inventory.txt is opened in writing mode, the user is then prompted to enter the nut of
they would like to delete, that value is then saved into the variable “i”. The program used a for
loop to shift each index in array 1 up from the selected nut, and then decrements the value of
line, the program then uses a for loop to print the updated values back to the stock, then closes
the file.
“Are you sure you want to delete the file” is printed and the user is asked to select a number
which will select a case structure. The program then accepts a number and then stores it in a
variable called “opt” if the user selects 1 the program check if “inventory.txt” is removed, if
deleted successfully "File deleted successfully" is printed to screen else, and error message is
printed. If the user selects 2 the program returns. Default case “not an option” is printed.
The user is prompted to enter the receipt number of a pervious order. That integer value is then
saved in the variable “order_num”, the program then opens the file with that order number in
Page | 6
reading mode , if it is found the program uses a while loop to print the contents. If not found “not
an order” is printed. The file is then closed.
A call to the fetch_inventory function is made, and a for loop is used to printed all the nuts and
their stock in the array.
A call to the fetch_inventory function is made, and the user is ask how many pounds they would
like to buy, the program saves that amount into the “amount” variable, if what they want is more
than what is in stock the program prints "We do not have that much in stock" and returns, else
total is calculated by “amount” * the price of the nut they selected, The file “inventory.txt” is
opened in writing mode. The stock of that nut is then updated and for loop is used to print the
updated values back to the file, the file is closed. The program then copies the data for the
nut_name, stock and price into the “a” index of the data array and grand total is calculated.
A call to the fetch_inventory function is made, and the user is ask how much’s worth they would
like to buy, the program saves that amount into the “price” variable, amount is calculated by
price divided by the price of the nut they selected if what they want is more than what is in stock
the program prints "We do not have that much in stock" and returns, else total is calculated by
“amount” * the price of the nut they selected, The file “inventory.txt” is opened in writing mode.
the stock of that nut is then updated and for loop is used to print the updated values back to the
file, the file is closed. The program then copies the data for the nut_name, stock and price into
the “a” index of the data array and grand total is calculated.
The program then sets the variable rec_number to the return value of the a_ran function. The
program opens the file “rec_number.txt” in writing mode, the Receipt number and the details of
all the nuts the customer bought are printed to the screen and the the file using a for loop. The
file is then closed.
Page | 7
Functional and Non-Functional Requirements
Functional Requirements:
Our program allows its users to access different menus like admin and customer, there is
also the option to leave the program.
The customer menu allows customers to enter the amount of nuts they'd like to purchase
then they are able to choose the type of nuts They'd like to purchase from the inventory.
After the selecting their nut of choice they are then able to choose how they'd like to
purchase the nut of their choice whether by weight or by quantity, if they choose to
purchase by weight then they are then able to enter how much pounds of the nut they'd
like, however if they chose to purchase by quantity then they are able to enter how much
money's worth of nuts they'd need and if there is not enough nuts available they will be
recommended to choose another nut option present.
The admin menu gives users the option to create a file which then allows them to access
their inventory so that they can edit it, by adding nuts to their inventory and remove nuts
from their inventory, also it allows users to change nut prices, names, stock and
manufacturer.
Non-Functional Requirements:
Our program has good usability, it has an intuitive user interface for both administrators
and customers and clear and concise prompts and messages for user interactions.
As it relates its performance, it's able to perform its duty well executing on its purpose as
it contains efficient file operations for reading and writing inventory data and has a quick
response time for menu navigation and order processing.
Now for its accuracy, it ensures accurate calculations for order totals and stock updates
and correctly displays inventory and receipt details.
About our program’s reliability, it is ensured that the system will operate correctly under
normal and exceptional conditions.
Our program has a security feature in place, as we input basic password protection
system for administrative access.
Page | 8
Scalability is also good as our program can Manage inventory and receipt files efficiently
regardless of their size.
Page | 9
User Manual
Upon First run of the program, the user must enter the admin menu first, using the password
“1234” then the user should select the option to create the file, the user is then to add all nuts
their nuts of choice alongside their relevant information; “Name, Stock (in pounds), price (in
JMD), Manufacture, and expiry date. After which that information will be saved in a file,
“inventory.txt” which will be used to operate the program for admin and customer use.
After entering the correct password, 6 options are presented to the user:
1. Change stock
The nuts are printed to screen with a number. The user should simply
select the number of the nut then would like to change the stock of. If the
user wishes to add stock, they should enter a positive integer if the wish to
subtract the enter a negative integer.
2. Change price
The nuts are printed to screen with a number. The user should simply
select the number of the nut then would like to change the price of and
simply enter the new price, that should be a positive integer.
3. Add nut
The user should enter the necessary information about the nut they wish to
add.
4. Delete Nut
The nuts are printed to screen with a number. The user should simply
select the number of the nut then would like to delete.
5. Search order.
The user should simply enter the receipt number of any purchase
previously made and the order details will be printed to screen.
6. Exit
Goodbye is printed and the program ends.
Page | 10
Customer Menu- This menu is made to handle purchases made by customers.
The user should enter the number of nuts they would like to buy, after which options are printed
are screen, after the user selects an option, they have the option to buy
1. By Pound
The user is to simply enters the number of pounds they would like to buy;
they will not be able to buy more than what they have in stock.
2. By Price
The user is to simply enter the amount’s worth of nuts they would want,
for example, $1000, also they will not be allowed to buy more than what
they have in stock.
After which a receipt will be printed to screen with their order details, and grand total.
Page | 11
System Architecture
Nuts Management
System
Admin Customer
Subsystem subsystem
Page | 12
Pseudocode
Module Name: Main
Structure declaration
Structure declaration
Page | 13
BEGIN MAIN
buy_num = 0
float grand_total = 0
print "Hello, Please Select which menu you would like to access"
read menu_option
switch (menu_option)
case 1:
if(inven == NULL)
read menu_option
switch (menu_option)
case 1:
Page | 14
print "File inventory.txt created.”
read num_nuts
read nutname
read stock
read price
read Manufacter
read expirey
endfor
break
case 2:
Exit.
Break
default:
break;
Page | 15
end switch
endif
else
read password
if (password == 1234)
clear screen.
Print"********************WELCOME ADMIN*******************"
print ""
read menu_option
switch (menu_option)
case 1:
Page | 16
print "Updated values"
break
case 2:
break
case 3:
break
case 4:
break
case 5:
break
case 6:
Page | 17
break
case 7:
print "Goodbye"
exit.
break
default:
exit
break
end switch
endif
endif
break
case 2:
read temp
buy_num = temp
Page | 18
print "Please select from the options above"
read buy
read opt
switch (opt)
case 1:
break
case 2:
break
default:
exit.
break
end switch
break
case 3:
print "Goodbye"
exit
Page | 19
break
default:
exit
break
end switch
END MAIN
BEGIN A_RAN
END A_RAN
BEGIN OPTIONS
declare i as integer
endfor
END OPTIONS
Page | 20
BEGIN FETCH_INVENTORY
begin
endfor
index = 0
index = index + 1
END FETCH_INVENTORY
BEGIN UPDATE_INVENTORY
declare j, i as integer
print "Enter the number of the nut you would like to change the stock of"
read i
Page | 21
print "Enter the amount of %s you would like to add or remove", nut[i-
1].NutName
read amount
if(stockg == NULL)
begin
endif
begin
enfor
END UPDATE_INVENTORY
BEGIN CHANGE_PRICE
declare i, j as integer
print "Enter the number of the nut you would like to change"
read i
Page | 22
print "Enter the new price of",nut[i-1].NutName
read c_price
begin
endfor
END CHANGE_PRICE
BEGIN ADD_NUT
declare j as integer
print "Enter the name of the nut you would like to add:"
read N_nut_name
read n_stock
read n_price
read N_Manufacter
Page | 23
read N_expirey
strcpy(nut[line].NutName, N_nut_name)
strcpy(nut[line].Manufacture, N_Manufacter)
strcpy(nut[line].expirey, N_expirey)
nut[line].stock = n_stock
nut[line].price = n_price
line = line + 1
begin
endfor
END ADD_NUT
BEGIN DELETE_NUT
begin
read indexx
Page | 24
begin
nut[j] = nut[j + 1]
end for
line = line - 1
begin
end for
END DELETE_NUT
BEGIN DELETE_FILE
read opt
switch (opt)
case 1:
if (remove("inventory.txt") == 0)
else
Page | 25
print "Error deleting file"
exit.
endif
break
case 2:
print "Goodbye"
exit
break
default:
exit.
break;
end switch
END DELETE_FILE
BEGIN FIND_ORDER
read order_num
if(order != NULL)
Page | 26
while (fgets(list_buffer, sizeof(list_buffer), order) != NULL)
print list_buffer
endwhile
end if
else
exit.
endif
END FIND_ORDER
declare i as integer
endfor
END CUS_OPTIONS
BEGIN BY_POUNDS
declare j as integer
Page | 27
call to the fetch_inventory function
print "How much pounds of", nut[buy-1].NutName", you would like to buy"
read amount
exit.
endif
else
endif
endfor
strcpy(data[a].Nut, nut[buy-1].NutName)
data[a].price = nut[buy-1].price
data[a].amount = amount
Page | 28
END BY_POUNDS
START BY_PRICE
declare j as integer
print "How much's worth of ", nut[buy-1].NutName," you would like to buy"
read price
exit.
else
endfor
Page | 29
strcpy(data[a].Nut, nut[buy -1].NutName)
data[a].price = nut[buy-1].price
data[a].amount = amount
END BY_PRICE
START RECEIPT_FUNCTION
print ""
print "********************************************"
endfor
Page | 30
print " Grand total"
print "********************************************"
endfor
END RECEIPT_FUNCTION
Page | 31
Test Plan
Page | 32
screen
5. Main 1 Allows the user The user will be Successful
to enter a choice allowed to enter
to select which a menu
menu they want
1234
to enter,
Page | 33
8. Main 2 Allows the user The user will be Successful
to enter a choice, allowed to enter
and how many a choice, and
nuts they would enter how many
1
like buy nuts they would
like to buy
Page | 34
Test Results
Page | 35
Page | 36
Page | 37
Page | 38