catalogue
3, Screenshot of operation results
2. Create inventory information
5, Other final course design systems (open source)
6, Attachment / download address
C language final course design
1, Description
hello everyone! I'm Xiao Tuzi. Today I'd like to share with you the final course design of C language - supermarket management system. This program is written in C language and the running environment is visual C++ 6.0, specific functions: establish inventory information, display all information, shopping cart, settlement, exit the system, etc. it is a good reference for learning C + + programs. The system runs in the command line window without visual interface and MFC class library. If friends use it to learn or do C language final course design homework, it must be possible, Let me share some with you!!! If you feel good, remember to give three company!!! Pro test is effective!!!
If you have any questions or comments, please contact me immediately:
CSDN:Little baby_ CSDN bloghttps://blog.csdn.net/m0_46843484?spm=1000.2115.3001.5343
Copyright notice: unless otherwise stated, the copyright of all articles on this blog belongs to the author. Reprint please indicate the source!
2, Function realization
1. Create inventory information
2. Show all information
3. Shopping cart
4. Settlement
5. Exit
3, Screenshot of operation results
1. System main interface
2. Create inventory information
3. Show all information
4. Shopping cart
5. Settlement
4, Program source code
If you establish a good development environment and copy the code directly, you can run it! Pro test valid!!!
#include<stdio.h> #include<stdlib.h> #include<string.h> #define NUM 5 /* [[baby] CSDN:https://blog.csdn.net/m0_46843484?spm=1011.2124.3001.5343*/ struct item{ char brand[20]; char id[10]; float in_price; float out_price; int storage; }; struct item_node{ struct item wanted; int amount; struct item_node *next; }; int menu(); void establish(); void dis_all(); void shop_cart(); int cart_menu(); void add(); void display(); void calculate(); struct item goods[NUM]; struct item_node *cart; void main() { printf("***********************************\n"); printf(" Welcome to the supermarket management system\n"); printf("***********************************\n"); while(1) { switch(menu()) { case 1: establish();break; case 2: dis_all();break; case 3: shop_cart();break; case 4: calculate();break; case 5: printf("Thanks for using. Bye!\n"); exit(0); } } } int menu() { char str[5]; int select; printf("\n\n Please select a number to operate\n"); printf("1.Create inventory information\n"); printf("2.Show all information\n"); printf("3.Shopping Cart\n"); printf("4.settlement\n"); printf("5.sign out\n"); printf("Please select the corresponding number:\n"); while(1) { fflush(stdin); gets(str); select=atoi(str); if(select<1||select>5) printf("Input error, please re-enter:"); else break; } return select; } void dis_all() { int i; FILE *fp; fp=fopen("goods","r"); for(i=0;(fread(goods+i,sizeof(struct item),1,fp))!=0;i++) { printf("---------------------------------\n"); printf("Product name and unit price Inventory\n"); printf("%s%7s%7.2f%8d\n",goods[i].id,goods[i].brand,goods[i].out_price,goods[i].storage); } fclose(fp); } void shop_cart() { while(1) { switch(cart_menu()) { case 1: display();break; case 2: add();break; case 3: return; } } } int cart_menu() { char str[5]; int select; printf("\n Please select an action\n"); printf("-----------------------\n"); printf("1.Displays the current shopping list\n"); printf("2.Add item\n"); printf("3.sign out\n"); printf("-----------------------\n\n"); while(1) { fflush(stdin); gets(str); select=atoi(str); if(select<1||select>3) printf("Input error, please re-enter:"); else break; } return select; } void display() { struct item_node *p=cart; if(p==NULL){ printf("Shopping cart is empty\n"); return ; } while(p!=NULL){ printf("----------------------------------\n"); printf("Article number Product name, unit price and quantity\n"); printf("%10s%20s%7.2f%8d\n",p->wanted.id,p->wanted.brand,p->wanted.out_price,p->amount); p=p->next; } } void add() { FILE *fp; int i,n; char str[20]; char choice1,choice2; struct item_node *p,*p1; do { printf("Enter the name or item number of the desired item: "); fflush(stdin); gets(str); if((fp=fopen("goods","r"))==NULL){ printf("fail to open file\n"); continue; } for(i=0;fread(goods+i,sizeof(struct item),1,fp)!=0;i++){ if((strcmp(goods[i].brand,str)==0||strcmp(goods[i].id,str)==0)&&goods[i].storage!=0){ printf("The required items have been found: \n"); printf("---------------------\n"); printf("Item No. item name unit price inventory quantity\n"); printf("%s%6s%3.2f%4d\n",goods[i].id,goods[i].brand,goods[i].out_price,goods[i].storage); printf("Please enter the required quantity: "); scanf("%d",&n); if(n>goods[i].storage){ printf("Insufficient inventory\n"); break; } printf("\n Buy or not?(Y/N)"); fflush(stdin); choice1=getchar(); if(choice1=='Y'||choice1=='y'){ p1=(struct item_node*)malloc(sizeof(struct item_node)); if(p1==NULL){ printf("Memory request failed!\n"); exit(1); } p1->amount=n; p1->wanted=goods[i]; p1->next=NULL; p=cart; if(cart==NULL) cart=p1; else{ while(p->next!=NULL) p=p->next; p1->next=p->next; p->next=p1; } } break; } } if(i==NUM) printf("Required item not found\n"); fclose(fp); printf("Continue shopping?(Y/N)"); fflush(stdin); choice2=getchar(); }while(choice2=='Y'||choice2=='y'); } void establish(){ FILE *fp; int i; printf("Please enter the cargo information in turn:\n"); printf("----------------------------\n"); for(i=0;i<NUM;i++) { printf("Product Name: "); fflush(stdin); gets(goods[i].brand); printf("Article number: "); fflush(stdin); gets(goods[i].id); printf("Purchase price: "); fflush(stdin); scanf("%f",&goods[i].in_price); printf("price: "); fflush(stdin); scanf("%f",&goods[i].out_price); printf("quantity: "); fflush(stdin); scanf("%d",&goods[i].storage); printf("\n"); } if((fp=fopen("goods","w"))==NULL){ printf("Failed to create file.\n"); return; } fwrite(goods,sizeof(struct item),NUM,fp); fclose(fp); } void calculate() { float total=0,pay; struct item_node *p; int i; FILE *fp; printf("Here is the shopping list: \n"); display(); if((fp=fopen("goods","r"))==NULL){ printf("fail to open file: \n"); return; } for(i=0;(fread(goods+i,sizeof(struct item),1,fp))!=0;i++); fclose(fp); p=cart; while(p!=NULL){ total+=p->wanted.out_price*p->amount; for(i=0;strcmp(goods[i].id,p->wanted.id)!=0;i++); goods[i].storage-=p->amount; p=p->next; } printf("total %7.2f",total); printf("\n Enter paid in amount: "); scanf("%f",&pay); printf("Paid in: %7.2f give change: %7.2f",pay,pay-total); if((fp=fopen("goods","w"))==NULL){ printf("fail to open file.\n"); return; } fwrite(goods,sizeof(struct item),NUM,fp); fclose(fp); }
5, Other final course design systems (open source)
C & C + + final course design -- student performance management source code_ Xiaotuzi CSDN blog
C & C + + final course design -- library management system source code_ Xiaotuzi CSDN blog
6, Attachment / download address
be careful
The download address of "25 +" C + + & & C language final course design (super detailed) is attached below. The introduction of each system introduces the implementation function of the system in detail, and you can find what you need according to the function.
C & C + + final course design
C & C + + - file grade (source code) - C/C + + Document Resources - CSDN Library
C language final course design
- Copyright notice: unless otherwise stated, the copyright of all articles on this blog belongs to the author. Reprint please indicate the source!