0% found this document useful (0 votes)
87 views6 pages

#Include #Include #Include #Include #Include #Define Z 100

This C program implements an inventory management system with functions for adding, modifying, and viewing product inventory, as well as making sales. It uses structures to store product data and includes functions for menu selection, password validation, finding available slots, and searching for products by name. The main function handles password checking and calls other functions based on the user's menu choice to carry out various inventory management tasks.

Uploaded by

sohagiut
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views6 pages

#Include #Include #Include #Include #Include #Define Z 100

This C program implements an inventory management system with functions for adding, modifying, and viewing product inventory, as well as making sales. It uses structures to store product data and includes functions for menu selection, password validation, finding available slots, and searching for products by name. The main function handles password checking and calls other functions based on the user's menu choice to carry out various inventory management tasks.

Uploaded by

sohagiut
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> #include<windows.

h> #define Z 100 struct Product { char item[100]; int qty; float price; } products[Z]; void start(void); void show_list(void); void func_modify(void); void make_sale(void); void func_enter(void); int menu_select(void); int find_free(void); int pas_check(void); int get_item(char*); int i,check;

int main() { char choice;

printf("\n\n\n\n\n\t\t\t__________WELCOME_________\n\n\n"); start(); check=pas_check(); if(check){ printf("\n\n\t\t\tAccess Allowed"); printf("\n\nPlease Wait\n\nLoading"); for(i=0;i<5;i++){ printf("."); Sleep(1000); } system("cls"); while(1) { choice = menu_select(); if(choice==1) { func_enter(); } else if (choice==2) { func_modify(); }

else if (choice==3) make_sale(); else if (choice==4) show_list(); else if(choice==5) { printf("please wait program is shutting down"); for(i=0;i<5;i++){ printf("-"); Sleep(500); } printf("\n\n\n"); exit(1); } system("cls"); } } else { printf("WRONG PASSWORD\n\nACCESS DENIED \n\n \t\t\tSYSTEM SHUTTING DOWN"); for(i=0;i<=5;i++){ printf("."); Sleep(1000); } printf("\n\n\n"); exit(1); } }

void start (void) { register int t; for(t=0; t<Z; ++t) products[t].item[0] = '\0';

int menu_select (void) { char s[80]; int c; printf("\n"); printf("\t\t\tl. printf("\t\t\t2. printf("\t\t\t3. printf("\t\t\t4. printf("\t\t\t5. do { printf("\nEnter your choice:"); gets(s); c = atoi(s); } while (c<0 || c>5); return c;

Enter an item\n"); Modify an item\n"); Make a sale\n"); Show inventroy list\n"); Exit\n");

void func_enter(void) { register int slot, len; char item[100]; slot = find_free(); if(slot == -1) { printf("\nlist full"); Sleep(2000); return; }

printf("\n\nEnter Item: "); gets(item); if(get_item(item)) { printf("\n\nItem Already Exist\nTry Again"); Sleep(2000); } else { strcpy(products[slot].item, item); printf("\nEnter price: "); scanf("%f", &products[slot].price); printf("\nEnter The Quantity: "); scanf("%d", &products[slot].qty); getchar(); printf("The given product is saved"); Sleep(2000); system("cls"); }

} int find_free(void) { register int t; for(t=0; products[t].item[0] && t<Z; ++t); if(t == Z) return -1; return t; } void func_modify(void){ int t; char s[80]; check=pas_check(); if( check){ printf("\nenter the name: ");

gets(s); t = get_item(s); if(t) { printf("\nenter the new quantity: "); scanf("%d", &products[t-1].qty); printf("The given product is modified"); Sleep(2000); system("cls"); return; } } else { printf("WRONG PASSWORD\n\n PLEASE TRY AGAIN:"); Sleep(1000); } system("cls"); menu_select();

void show_list(void){ register int t; float sum=0; check=pas_check(); if(check){ system("cls"); printf("\n\n\t\t\tcomplete list for(t=0; t<Z; ++t) { if (products[t].item[0]) { printf("item: %s\n", products[t].item); printf("price: %f\n", products[t].price); printf( "quantity: %d\n\n", products[t].qty); sum = sum + products[t].price*products[t].qty;

is shown below\n\n");

} } printf("\n\nTotal Budget: %f\n\n", sum); printf("\n\n\tpress!\n\n1.GO BACK TO MAIN\n2.EXIT\n\nENTER A CHOICE:"); scanf("%d",&i); if(i==1) { system("cls"); menu_select(); } else { printf("please wait program is shutting down"); for(i=0;i<5;i++){ printf("-"); Sleep(500); } printf("\n\n\n"); exit(1); }

else { printf("WRONG PASSWORD\n\n PLEASE TRY AGAIN:"); Sleep(1000); system("cls"); menu_select();}

int get_item(char *ptr){ int t; for(t=0; t<Z; t++) { if (strcmp(products[t].item, ptr) == 0) { return t+1; } } return 0; } void make_sale(){ char item[100]; int t, quant; printf("\nEnter the name: "); gets(item); t = get_item(item); if(t) { printf("\nQuantity: "); scanf("%d",&quant); if(quant < products[t-1].qty) { products[t-1].qty = products[t-1].qty - quant ; printf("The given product is sold"); Sleep(2000); system("cls"); }

else { printf("\nNot enough item\n"); Sleep(1000); } } else {

printf("\nItem not available\n"); Sleep(1000); } } int pas_check(){ char char char char pass[] = "faRHAD09#"; name[]= "admin"; temp1[80]; temp[15];

printf("\n\n\n\n\t\t\tUser Name: "); gets(temp1); printf("\t\t\tPassword: "); gets(temp); if(strcmp(name,temp1) == 0 && strcmp(pass, temp) == 0) return 1; else return 0;

/*

NAME : FARHAD ID : 122309(HD) PROGRAMMING PROJECT

*/

You might also like