Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a C program on this Create an Inventory Control Program, called ICP.exe. T

ID: 3603485 • Letter: W

Question

write a C program on this Create an Inventory Control Program, called ICP.exe. This program will provide the user with a menu of actions to control inventory, which include: list the inventory, create an item, add inventory, remove inventory, delete item, import and export database. An inventory item has a: Unique ID, Part NO, Names, Quantity, and Sale Price, and Unit Price. Load a database with the following items: 1. SNK809a Seiko Automatic Men's Watch, 10, $75, $70. 2. SR400 Yamaha 400cc Motorcycle, 3, $5,999, $4,000. 3. Soundlink-Coral Bose Bluetooth Speaker in Coral Red, 20, $129, $89. Demonstrate loading/creating a database of inventory, creating new items, adding to inventory, removing from inventory, and saving the database. Capture your output with the snipping tool. A menu might look like the following, but the student is free to create a different interface, if it is more intuitive. c:usersdbs0011icp.exe Welcome to the Inventory Control Program! select from the following (L)ist, (C)reate, (A)dd, (R)emove, (I)mport, or (E)xport:> I enter the DB name to import:> first.db first.db imported. select from the following (L)ist, (C)reate, (A)dd, (R)emove, (I)mport, or (E)xport:> I Build the Import and Export functions last as we will not cover files until right before the end of this project. Use dynamic memory allocation for your records. Each interface option should be a separate function. Use structures to define your inventory items. Use separate C files to encapsulate your user interface, data storage and test functions. I have to use the code given below in this format. I have been stuck using Xcode and i have a few bugs. I would appreciate if you can view my code and errors to help me get this up and running. Here is all my code: the first of 3 is a header file: #define TRUE 1 #define FALSE 0 typedef struct { int id; char name[50]; char partNo[30]; float price; float cost; int quantity; }item_t; int createItem(); int writeInventory(); item_t *readInventory(); int printInventory(void); with 3 errors before the last line of code saying This function declaration is not a prototype Next file linked to the header is inventory2.c #include #include #include #include "inventory2.h" item_t *inventory[30]; int next=0; int getNextId() { static int id=0; return id++; } void printItem(item_t *p){ printf(" part name: %s", p->name); printf(" part number: %s", p->partNo); printf("n part quantity: %d", p->quantity); printf(" part price: %f", p->price); printf("n part cost: %f", p->cost); } printInventory() { register int i; for(i=0; iid=getNextId(); printf(" Enter part name: "); fgets(p->name, 50, stdin); p->name[strlen(p->name)-1] = ''; printf(" Enter part number "); fgets(p->partNo, 30, stdin); p->partNo[strlen(p->partNo)-1] = '0'; printf(" Enter part quantity: "); fgets(buf, 50, stdin); buf[strlen(buf)-1] = ''; p->quantity = atoi(buf); printf("n Enter part price: "); fgets(buf, 50, stdin); buf[strlen(buf)-1] = ''; p->price = (float) atof(buf); printf("n Enter part cost: "); fgets(buf, 50, stdin); buf[strlen(buf)-1] = ''; p->cost = (float) atof(buf); inventory[next++] = p; return TRUE; } int writeInventory() { FILE *fp; int num, i; item_t*p; fp = fopen("inventory.db", "rb"); for(i=0; i #include #include "inventory2.h" int mainMenu (){ char buf[50], *p; buf[0] = ''; printf(" Select from the following commandsL (L)ist, (A)dd, (R)emove, (I)mport, (E)xport, or (Q)uit: "); fgets(buf, 50, stdin); buf[strlen(buf) -1] = ''; p = strupr(buf); switch(*p) { case 'L': printInventory(); break; case 'A': createItem(); break; case 'R': case 'I': readInventory(); break; case 'E': case 'Q': writeInventory(); return FALSE; default: printf(" ERROR: invalid option selected! "); } return TRUE; } int main (void) { item_t *i; int loop = TRUE; while (loop) { loop= mainMenu(); } return 0; } line 22 error: p = strupr(buf); This function declaration is not a prototype Incompatible integer to pointer conversion assigning to 'char *' from 'int' Implicit declaration of function 'strupr' is invalid in C99 item_t *i; line 46 error: unused variable i

Explanation / Answer

#include void main() { struct date { int day; int month; int year; }; struct details { char name[20]; int price; int code; int qty; struct date mfg; }; struct details item[50]; int n, i; printf("Enter number of items:"); scanf("%d", &n); fflush(stdin); for (i = 0; i