
December 3rd, 2012, 08:41 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Time spent in forums: 18 m 40 sec
Reputation Power: 0
|
|
|
#include <stdio.h>
#define item 100
#define quantity 100
#define price 100
typedef struct Management
{
char arrayi;
int arrayq;
float arrayp;
}RECORD;
void addToInventory(RECORD one,int *totalItems);
void displayInventory(RECORD one,int totalItems);
void inventorySave(RECORD one, int totalItems);
int main()
{
int x;
int y=1;
int totalItems=0;
RECORD one[100];
while(y==1)
{//begining of while
printf("1. Add to Inventory\n");
printf("2. Adjust Quantity of an Item\n");
printf("3. Print Inventory\n");
printf("4. Remove an Item from Inventory\n");
printf("5. Quit and Save inventory\n");
scanf("%d",&x);
switch(x)//begining of switch
{
case(1):
addToInventory(*one,&totalItems);//function call
break;
case(2):
printf("The user chose to adjust the quantity of an item.\n");
break;
case(3):
displayInventory(one,totalItems);//function call
break;
case(4):
printf("The user has chosen to remove an item from inventory.\n");
break;
case(5):
inventorySave(one,totalItems);//save function
printf("All items have been saved and the program has been quit.\n");
y++;//ends switch
break;
}
}
}//end of main
void addToInventory(RECORD one,int *totalItems)
{
printf("Enter the item being added to the inventory.\n");
scanf("%s",one[*totalItems].arrayi);//item
printf("Enter the quantity of the item.\n");
scanf("%d",&(one[*totalItems].arrayq));//quantity
printf("Enter the price of the item.\n");
scanf("%f",&(one[*totalItems].arrayp));//price
(*totalItems)++;//+1 to total items
}
void displayInventory(RECORD one,int totalItems)
{
int x=0;
printf(" Item Quantity Price\n\n");
for(x=0;x<totalItems;x++)
{
printf("%10s",one[x].arrayi);
printf("%17d",one[x].arrayq);
printf("%13.2f\n",one[x].arrayp);
}
}
void inventorySave(RECORD one,int totalItems)
{
}
|