SlideShare a Scribd company logo
I really need help with this Assignment Please in C programming not C++ or C#, just C. Thank
you!
Hello , Choose please one of the following program types:
The assignment is to write a menu driven program that manages a small business inventory,
collection or list. You pick the topic. The focus of your program is up to you.
The Menu commands must include:
P....Display all records (on the screen/monitor) S....Create a current report (save it to a file)
A....Add a new entry
D....Delete an item from the list (inventory) C....Clear all records
Q...Quit
You must add (1) additional menu option that you choose. It may be a menu option that allows
the inventory to be modified. i.e. add inventory quantities, change price/cost, change dates, etc.
You will use structs and an array to organize the data in the program. Your struct must contain
at least the following kinds of information: o Minimum of 2 strings (character arrays)
Suggestions include: item name, manufacturer, etc o Minimum of 2 integers – 1 must be product
id
Product id, qty in stock o Minimum of 2 double values
Suggestions include: cost, price, average inventory:
When you add new item the program will ask the user for each of the fields on a separate line.
When you delete an item from inventory the program will ask you for the integer id of the entry
to be deleted, locate the entry in the array and remove all of the data for that entry. – The list
does not need to be sorted – to remove an entry, you may move the last item in the list to the
location of the deleted entry
When you display the records on the screen, all of the information stored for each entry will be
labeled and displayed.
Creating a current inventory report copies the current entries in the array to an output file. This
must include labeling all of the information so that it is clear what information is being provided.
Clearing the records deletes all of the information in the array.
When you add new item the program will ask the user for each of the fields on a separate line.
When you delete a question from the list, the program will ask you for the question id of the
entry to be deleted, locate the entry in the array and remove all of the data for that entry. – The
list does not need to be sorted – to remove an entry, you may move the last item in the list to the
location of the deleted entry
When you play the game, you must display the question, the possible answers and the point
value. If the player answers correctly the point value will be added to the game total. If answered
incorrectly, the correct answer will be displayed. Creating a current report copies the current
content of the question array to an output file. This must include labeling all of the information
so that it is clear what information is being provided.
Clearing all questions deletes all of the information in the array.
Instructions:
You should use at least 10 user-defined functions (plus main) to appropriately break the problem
up into smaller pieces.
Your program must start up with at least 5 valid records or questions. These records must be
“hard coded” in your program file. (This can be done in one of your user-defined functions)
You need to begin the program with general instructions on your program, an outline of the data
fields and the format needed to enter the data You should use function prototypes and NO global
variables.
You should use a #define to set the upper bound of the list to at least 50 entries.
Your code should be well designed, well commented and written with good style.
Solution
#include
#include
#include
#define MAXIMUM_ENTRIES 50
typedef struct{
char prod_name[20];
char brand[20];
int prod_id;
int stock;
double price;
double avginventory;
} purse;
void initializeEntries(purse list[],int *size)
{
strcpy(list[0].prod_name,"Goodday cashew");
strcpy(list[0].brand,"Goodday");
list[0].prod_id=100;
list[0].stock=101;
list[0].price=500;
list[0].avginventory=200.2;
strcpy(list[1].prod_name,"Goodday butter");
strcpy(list[1].brand,"Goodday");
list[1].prod_id=101;
list[1].stock=101;
list[1].price=300;
list[1].avginventory=200.2;
strcpy(list[2].prod_name,"Salt&Pepper");
strcpy(list[2].brand,"Goodday");
list[2].prod_id=102;
list[2].stock=101;
list[2].price=325;
list[2].avginventory=200.2;
strcpy(list[3].prod_name,"BadamwithPista");
strcpy(list[3].brand,"Goodday");
list[3].prod_id=103;
list[3].stock=101;
list[3].price=365;
list[3].avginventory=200.2;
strcpy(list[4].prod_name,"Sweet&Salt");
strcpy(list[4].brand,"Goodday");
list[4].prod_id=104;
list[4].stock=101;
list[4].price=595;
list[4].avginventory=200.2;
*size=5;
return;
}
char menu()
{
char sel;
printf(" *************************************** ");
printf("Please select on of the options below: ");
printf("A - ADD a new entry ");
printf("D - DELETE an entry ");
printf("P - PRINT entire catalog ");
printf("S - SAVE the current catalog ");
printf("C - CLEAR the entire catalog ");
printf("U - UPDATE the price ");
printf("Q - QUIT ");
printf("Which option you want to select: ");
scanf(" %c",&sel);
return sel;
}
void addEntry(purse list[],int *size)
{
printf(" Enter name : ");
scanf("%s",list[*size].prod_name);
printf(" Enter brand : ");
scanf("%s",list[*size].brand);
printf(" Enter id : ");
scanf("%d",&list[*size].prod_id);
printf(" Enter stock : ");
scanf("%d",&list[*size].stock);
printf(" Enter price : ");
scanf("%lf",&list[*size].price);
printf(" Enter average inventory : ");
scanf("%lf",&list[*size].avginventory);
(*size)++;
return;
}
void deleteEntry(purse list[],int *size)
{
int i, prod_id;
printf("List of ID #'s: ");
for(i=0;i<*size;i++)
printf("%d ",list[i].prod_id);
printf(" Please enter the I.D.: ");
scanf("%d",&prod_id);
for(i=0;i<*size;i++)
{
if(list[i].prod_id == prod_id)
{
strcpy(list[i].brand,list[*size-1].brand);
strcpy(list[i].prod_name,list[*size-1].prod_name);
list[i].id = list[*size-1].id;
list[i].stock = list[*size-1].stock;
list[i].price = list[*size-1].price;
list[i].avginventory = list[*size-1].avginventory;
(*size)--;
break;
}
}
return;
}
void display(purse list[],int *size)
{
int i;
if(*size==0)printf("*****Catalog is empty***** ");
for(i=0;i<*size;i++)
{
printf("---Catalog Entry %d--- ",i+1);
printf("BRAND: %s ",list[i].brand);
printf("NAME: %s ",list[i].prod_name);
printf("I.D.#: %d ",list[i].prod_id);
printf("QTY: %d ",list[i].stock);
printf("PRICE: $%.2lf ",list[i].price);
printf("AVERAGE INVENTORY: $%,2lf  ",list[i].avginventory);
}
return;
}
void createReport(purse list[],int *size)
{
FILE *f;
int i;
f=fopen("Records.txt","w");
if (f == NULL)
{
printf("Error opening file! ");
exit(1);
}
if(*size==0)
fprintf(f,"*****Catalog is empty***** ");
for(i=0;i<*size;i++)
{
fprintf(f, "---Catalog Entry %d--- ",i+1);
fprintf(f,"BRAND: %s ",list[i].brand);
fprintf(f,"NAME: %s ",list[i].prod_name);
fprintf(f,"I.D.#: %d ",list[i].prod_id);
fprintf(f,"QTY: %d ",list[i].stock);
fprintf(f,"PRICE: $%.2lf ",list[i].price);
fprintf(f,"AVERAGE INVENTORY: $%.2lf  ",list[i].avginventory);
}
fclose(f);
return;
}
void clearRecords(purse list[],int *size)
{
*size=0;
return;
}
void update(purse list[],int *size)
{
int i,prod_id;
double price_up;
printf("List of ID #'s: ");
for(i=0;i<*size;i++)
printf("%d ",list[i].prod_id);
printf(" Please enter the I.D.: ");
scanf("%d",&prod_id);
for(i=0;i<*size;i++)
{
if(list[i].prod_id==prod_id)
{
printf("---Catalog Entry %d--- ",i+1);
printf("BRAND: %s ",list[i].brand);
printf("NAME: %s ",list[i].prod_name);
printf("I.D.#: %d ",list[i].prod_id);
printf("QTY: %d ",list[i].stock);
printf("PRICE: $%.2lf ",list[i].price);
printf("AVERAGE INVENTORY: $%.2lf  ",list[i].avginventory);
printf("Please enter the updated price: ");
scanf("%lf",&price_up);
list[i].price = price_up;
break;
}
}
return;
}
int main(){
purse list[MAX_ENTRIES];
int size=0;
initializeEntries(list,&size);
printf("Hello and welcome. This program helps you create an inventory for Biscuits. ");
printf("To get you started, 5 brands of biscuits have already been entered. ");
while(1){
char sel=menu();
if(sel=='A' || sel=='a'){
addEntry(list,&size);
}
else if(sel=='D' || sel=='d'){
deleteEntry(list,&size);
}
else if(sel=='P' || sel=='p'){
display(list,&size);
}
else if(sel=='S' || sel=='s'){
createReport(list,&size);
}
else if(sel=='C' || sel=='c'){
clearRecords(list,&size);
}
else if(sel=='U' || sel=='u'){
update(list,&size);
}
else if(sel=='Q' || sel=='q'){
printf("Goodbye. ");
break;
}
else printf("Enter a valid Option ");
}
return 0;
}

More Related Content

Similar to I really need help with this Assignment Please in C programming not .pdf (20)

DOCX
Program Specifications Develop an inventory management system for an e.docx
VictormxrPiperc
 
PDF
12.9 Program Online shopping cart (continued) (C++)This program e.pdf
fasttracksunglass
 
DOCX
Cover PageComplete and copy the following to Word for your cover p.docx
faithxdunce63732
 
PDF
show code and all classes with full implementation for these Program S.pdf
AlanSmDDyerl
 
DOCX
You are to write a program that computes customers bill for hisher.docx
ajoy21
 
DOCX
Program Specifications in c++ Develop an inventory management system f.docx
sharold2
 
DOCX
Program Specifications in c++ Develop an inventory management syste.docx
sharold2
 
DOCX
Question 1 briefly respond to all the following questions. make
YASHU40
 
PDF
For this homework, you will write a program to create and manipulate.pdf
herminaherman
 
DOCX
CS10 Python Programming Homework 4 40 points Lists, Tupl.docx
mydrynan
 
PDF
BIS 155 PAPERS Education Counseling--bis155papers.com
venkat60036
 
PDF
BIS 155 PAPERS Inspiring Innovation--bis155papers.com
sachin10101
 
PPT
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
cskvsmi44
 
PPT
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
noahjamessss
 
DOCX
BIS 155 Inspiring Innovation -- bis155.com
kopiko101
 
DOCX
BIS 155 Lessons in Excellence / bis155.com
kopiko33
 
PDF
BIS 155 PAPERS Become Exceptional--bis155papers.com
KeatonJennings119
 
PDF
BIS 155 PAPERS Redefined Education--bis155papers.com
agathachristie241
 
PDF
BIS 155 PAPERS Introduction Education--bis155papers.com
agathachristie256
 
PDF
BIS 155 PAPERS Lessons in Excellence--bis155papers.com
thomashard72
 
Program Specifications Develop an inventory management system for an e.docx
VictormxrPiperc
 
12.9 Program Online shopping cart (continued) (C++)This program e.pdf
fasttracksunglass
 
Cover PageComplete and copy the following to Word for your cover p.docx
faithxdunce63732
 
show code and all classes with full implementation for these Program S.pdf
AlanSmDDyerl
 
You are to write a program that computes customers bill for hisher.docx
ajoy21
 
Program Specifications in c++ Develop an inventory management system f.docx
sharold2
 
Program Specifications in c++ Develop an inventory management syste.docx
sharold2
 
Question 1 briefly respond to all the following questions. make
YASHU40
 
For this homework, you will write a program to create and manipulate.pdf
herminaherman
 
CS10 Python Programming Homework 4 40 points Lists, Tupl.docx
mydrynan
 
BIS 155 PAPERS Education Counseling--bis155papers.com
venkat60036
 
BIS 155 PAPERS Inspiring Innovation--bis155papers.com
sachin10101
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
cskvsmi44
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
noahjamessss
 
BIS 155 Inspiring Innovation -- bis155.com
kopiko101
 
BIS 155 Lessons in Excellence / bis155.com
kopiko33
 
BIS 155 PAPERS Become Exceptional--bis155papers.com
KeatonJennings119
 
BIS 155 PAPERS Redefined Education--bis155papers.com
agathachristie241
 
BIS 155 PAPERS Introduction Education--bis155papers.com
agathachristie256
 
BIS 155 PAPERS Lessons in Excellence--bis155papers.com
thomashard72
 

More from pasqualealvarez467 (20)

PDF
In general diffusion is faster forA. less closely packed structure.pdf
pasqualealvarez467
 
PDF
In your own words 1.Explain what a semiconductor is. 2.Describe one.pdf
pasqualealvarez467
 
PDF
If the random variable X is normally distributed with mean and stand.pdf
pasqualealvarez467
 
PDF
I have a Computer Archtecture book and notes that describe addressin.pdf
pasqualealvarez467
 
PDF
Identify opportunities for leadership for sustainability in personal.pdf
pasqualealvarez467
 
PDF
Gametes that contain new combinations of alleles not present in the .pdf
pasqualealvarez467
 
PDF
From Figure 26 what is true of Dryopithecus and Ouranopithecus 1.) .pdf
pasqualealvarez467
 
PDF
F. Chlorine Content F1. What type of sample might be expected to cont.pdf
pasqualealvarez467
 
PDF
Describe each level of cache. Time sharing systems do what for the u.pdf
pasqualealvarez467
 
PDF
Clearly explain why 2D surface measurement can be unrealisticSo.pdf
pasqualealvarez467
 
PDF
c++ early objectsc++ early objectsc++ early objectsSol.pdf
pasqualealvarez467
 
PDF
As part of an IT survey, both staff and managers were asked to indic.pdf
pasqualealvarez467
 
PDF
a. High Frequency components delayedb. Low frequency components lo.pdf
pasqualealvarez467
 
PDF
A signal y(t) is periodic with fundamental period T0, and is the sum.pdf
pasqualealvarez467
 
PDF
A die is thrown. Let E be the event that the number thrown is even a.pdf
pasqualealvarez467
 
PDF
4. A gaseous fuel contains the following by mole 31.3 C2H6; 67.6 .pdf
pasqualealvarez467
 
PDF
2. What factors should be considered in selecting a design strategy.pdf
pasqualealvarez467
 
PDF
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
pasqualealvarez467
 
PDF
Why is mild to moderate expression of an X-linked recessive trait no.pdf
pasqualealvarez467
 
PDF
Wireless networks are considered insecure for many organizations; es.pdf
pasqualealvarez467
 
In general diffusion is faster forA. less closely packed structure.pdf
pasqualealvarez467
 
In your own words 1.Explain what a semiconductor is. 2.Describe one.pdf
pasqualealvarez467
 
If the random variable X is normally distributed with mean and stand.pdf
pasqualealvarez467
 
I have a Computer Archtecture book and notes that describe addressin.pdf
pasqualealvarez467
 
Identify opportunities for leadership for sustainability in personal.pdf
pasqualealvarez467
 
Gametes that contain new combinations of alleles not present in the .pdf
pasqualealvarez467
 
From Figure 26 what is true of Dryopithecus and Ouranopithecus 1.) .pdf
pasqualealvarez467
 
F. Chlorine Content F1. What type of sample might be expected to cont.pdf
pasqualealvarez467
 
Describe each level of cache. Time sharing systems do what for the u.pdf
pasqualealvarez467
 
Clearly explain why 2D surface measurement can be unrealisticSo.pdf
pasqualealvarez467
 
c++ early objectsc++ early objectsc++ early objectsSol.pdf
pasqualealvarez467
 
As part of an IT survey, both staff and managers were asked to indic.pdf
pasqualealvarez467
 
a. High Frequency components delayedb. Low frequency components lo.pdf
pasqualealvarez467
 
A signal y(t) is periodic with fundamental period T0, and is the sum.pdf
pasqualealvarez467
 
A die is thrown. Let E be the event that the number thrown is even a.pdf
pasqualealvarez467
 
4. A gaseous fuel contains the following by mole 31.3 C2H6; 67.6 .pdf
pasqualealvarez467
 
2. What factors should be considered in selecting a design strategy.pdf
pasqualealvarez467
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
pasqualealvarez467
 
Why is mild to moderate expression of an X-linked recessive trait no.pdf
pasqualealvarez467
 
Wireless networks are considered insecure for many organizations; es.pdf
pasqualealvarez467
 
Ad

Recently uploaded (20)

PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Ad

I really need help with this Assignment Please in C programming not .pdf

  • 1. I really need help with this Assignment Please in C programming not C++ or C#, just C. Thank you! Hello , Choose please one of the following program types: The assignment is to write a menu driven program that manages a small business inventory, collection or list. You pick the topic. The focus of your program is up to you. The Menu commands must include: P....Display all records (on the screen/monitor) S....Create a current report (save it to a file) A....Add a new entry D....Delete an item from the list (inventory) C....Clear all records Q...Quit You must add (1) additional menu option that you choose. It may be a menu option that allows the inventory to be modified. i.e. add inventory quantities, change price/cost, change dates, etc. You will use structs and an array to organize the data in the program. Your struct must contain at least the following kinds of information: o Minimum of 2 strings (character arrays) Suggestions include: item name, manufacturer, etc o Minimum of 2 integers – 1 must be product id Product id, qty in stock o Minimum of 2 double values Suggestions include: cost, price, average inventory: When you add new item the program will ask the user for each of the fields on a separate line. When you delete an item from inventory the program will ask you for the integer id of the entry to be deleted, locate the entry in the array and remove all of the data for that entry. – The list does not need to be sorted – to remove an entry, you may move the last item in the list to the location of the deleted entry When you display the records on the screen, all of the information stored for each entry will be labeled and displayed. Creating a current inventory report copies the current entries in the array to an output file. This must include labeling all of the information so that it is clear what information is being provided. Clearing the records deletes all of the information in the array. When you add new item the program will ask the user for each of the fields on a separate line. When you delete a question from the list, the program will ask you for the question id of the entry to be deleted, locate the entry in the array and remove all of the data for that entry. – The list does not need to be sorted – to remove an entry, you may move the last item in the list to the location of the deleted entry When you play the game, you must display the question, the possible answers and the point value. If the player answers correctly the point value will be added to the game total. If answered
  • 2. incorrectly, the correct answer will be displayed. Creating a current report copies the current content of the question array to an output file. This must include labeling all of the information so that it is clear what information is being provided. Clearing all questions deletes all of the information in the array. Instructions: You should use at least 10 user-defined functions (plus main) to appropriately break the problem up into smaller pieces. Your program must start up with at least 5 valid records or questions. These records must be “hard coded” in your program file. (This can be done in one of your user-defined functions) You need to begin the program with general instructions on your program, an outline of the data fields and the format needed to enter the data You should use function prototypes and NO global variables. You should use a #define to set the upper bound of the list to at least 50 entries. Your code should be well designed, well commented and written with good style. Solution #include #include #include #define MAXIMUM_ENTRIES 50 typedef struct{ char prod_name[20]; char brand[20]; int prod_id; int stock; double price; double avginventory; } purse; void initializeEntries(purse list[],int *size) { strcpy(list[0].prod_name,"Goodday cashew"); strcpy(list[0].brand,"Goodday"); list[0].prod_id=100; list[0].stock=101; list[0].price=500;
  • 4. printf(" *************************************** "); printf("Please select on of the options below: "); printf("A - ADD a new entry "); printf("D - DELETE an entry "); printf("P - PRINT entire catalog "); printf("S - SAVE the current catalog "); printf("C - CLEAR the entire catalog "); printf("U - UPDATE the price "); printf("Q - QUIT "); printf("Which option you want to select: "); scanf(" %c",&sel); return sel; } void addEntry(purse list[],int *size) { printf(" Enter name : "); scanf("%s",list[*size].prod_name); printf(" Enter brand : "); scanf("%s",list[*size].brand); printf(" Enter id : "); scanf("%d",&list[*size].prod_id); printf(" Enter stock : "); scanf("%d",&list[*size].stock); printf(" Enter price : "); scanf("%lf",&list[*size].price); printf(" Enter average inventory : "); scanf("%lf",&list[*size].avginventory); (*size)++; return; } void deleteEntry(purse list[],int *size) { int i, prod_id; printf("List of ID #'s: "); for(i=0;i<*size;i++) printf("%d ",list[i].prod_id);
  • 5. printf(" Please enter the I.D.: "); scanf("%d",&prod_id); for(i=0;i<*size;i++) { if(list[i].prod_id == prod_id) { strcpy(list[i].brand,list[*size-1].brand); strcpy(list[i].prod_name,list[*size-1].prod_name); list[i].id = list[*size-1].id; list[i].stock = list[*size-1].stock; list[i].price = list[*size-1].price; list[i].avginventory = list[*size-1].avginventory; (*size)--; break; } } return; } void display(purse list[],int *size) { int i; if(*size==0)printf("*****Catalog is empty***** "); for(i=0;i<*size;i++) { printf("---Catalog Entry %d--- ",i+1); printf("BRAND: %s ",list[i].brand); printf("NAME: %s ",list[i].prod_name); printf("I.D.#: %d ",list[i].prod_id); printf("QTY: %d ",list[i].stock); printf("PRICE: $%.2lf ",list[i].price); printf("AVERAGE INVENTORY: $%,2lf ",list[i].avginventory); } return; } void createReport(purse list[],int *size) {
  • 6. FILE *f; int i; f=fopen("Records.txt","w"); if (f == NULL) { printf("Error opening file! "); exit(1); } if(*size==0) fprintf(f,"*****Catalog is empty***** "); for(i=0;i<*size;i++) { fprintf(f, "---Catalog Entry %d--- ",i+1); fprintf(f,"BRAND: %s ",list[i].brand); fprintf(f,"NAME: %s ",list[i].prod_name); fprintf(f,"I.D.#: %d ",list[i].prod_id); fprintf(f,"QTY: %d ",list[i].stock); fprintf(f,"PRICE: $%.2lf ",list[i].price); fprintf(f,"AVERAGE INVENTORY: $%.2lf ",list[i].avginventory); } fclose(f); return; } void clearRecords(purse list[],int *size) { *size=0; return; } void update(purse list[],int *size) { int i,prod_id; double price_up; printf("List of ID #'s: "); for(i=0;i<*size;i++) printf("%d ",list[i].prod_id); printf(" Please enter the I.D.: ");
  • 7. scanf("%d",&prod_id); for(i=0;i<*size;i++) { if(list[i].prod_id==prod_id) { printf("---Catalog Entry %d--- ",i+1); printf("BRAND: %s ",list[i].brand); printf("NAME: %s ",list[i].prod_name); printf("I.D.#: %d ",list[i].prod_id); printf("QTY: %d ",list[i].stock); printf("PRICE: $%.2lf ",list[i].price); printf("AVERAGE INVENTORY: $%.2lf ",list[i].avginventory); printf("Please enter the updated price: "); scanf("%lf",&price_up); list[i].price = price_up; break; } } return; } int main(){ purse list[MAX_ENTRIES]; int size=0; initializeEntries(list,&size); printf("Hello and welcome. This program helps you create an inventory for Biscuits. "); printf("To get you started, 5 brands of biscuits have already been entered. "); while(1){ char sel=menu(); if(sel=='A' || sel=='a'){ addEntry(list,&size); } else if(sel=='D' || sel=='d'){ deleteEntry(list,&size); } else if(sel=='P' || sel=='p'){ display(list,&size);
  • 8. } else if(sel=='S' || sel=='s'){ createReport(list,&size); } else if(sel=='C' || sel=='c'){ clearRecords(list,&size); } else if(sel=='U' || sel=='u'){ update(list,&size); } else if(sel=='Q' || sel=='q'){ printf("Goodbye. "); break; } else printf("Enter a valid Option "); } return 0; }