(C语言)换热器报价生成器设计报告

目录
1. 课题概述
1.1课题目标和主要内容
1.2系统的主要功能
1.2.1.功能列表
1.2.2 显示分项价格【以板片为例】
2. 系统设计
2.1 系统总体框架
2.2 系统详细设计
3. 程序运行结果分析
【附件】
1.源代码
(1). pay.c
(2). bar and pad.h
(3) . kuangjia.h
(4) . falan.h
(5) . pack.h
(6) . dituo.h
2. 价格表文件
(1) . 板片及垫片.txt
(2) . 框架.txt
(3) . 法兰.txt
(4) . 包装.txt
(5) . 底托.txt

源代码文件等
链接:http://pan.baidu.com/s/1bphcoRP 密码:bcpi

1. 课题概述

1.1课题目标和主要内容

根据选型结果自动生成报价
开发平台:windows32系统
运行平台:windows
开发工具:Visual studio 2010

1.2系统的主要功能

1.2.1.功能列表

(1)报价:录入产品型号,输出总价格:  Cost()函数实现
    【注:换热器价格=板片价格(板片面积*板片单价)+框架价格+法兰价格+包装/底托价格】

(2)显示分项价格:录入部件名称,输出相应的价目表格在屏幕上:   view()函数实现

这里写图片描述
1.2.2 显示分项价格【以板片为例】

 (1).从文件中读取数据存入链表:createlink_pad()函数实现
 (2).输出链表数据到屏幕:outlink_pad(node_pad *head)函数实现

3.计算部件价格(用于作运算总价):

    search_pad(node_pad *head,char type[])函数实现

2. 系统设计

2.1 系统总体框架

  系统框架图或层次逻辑图

系统框架图或层次逻辑图
设计思想

1.通过输入的字符选择计算总报价或显示分项价格
2.每个分项的函数里,将此分项的价格读取并保存到一个结构体里
3.将结构体里的数据以表格的形式输出显示

2.2 系统详细设计

见附件

3.程序运行结果分析

菜单
运算
价目表

【附件】
1.源代码
(1). pay.c

#include<stdio.h>
#include<stdlib.h>
#include<memory.h>

#include"goodmorning.h"
#include"bar and pad.h"
#include"pack.h"
#include"kuangjia.h"
#include"dituo.h"
#include"falan.h"

typedef struct node {
    char data[20];
    struct node *next;
}node;




void Cost()//算总价
{
    void extract(char all[],char impart[]);
    node *head;
    float cost_pad=0,cost_kj=0,cost_fl=0,cost_bz=0,cost_dt=0,cost_hrq=0;
    char type[10];
    char vi_type[10]={0};
    float pad_area;

    int i;
    char fl,bd;

    do
    {
        printf("input type  : ");//型号
        scanf("%s",type);
//strcpy(type,"BP100B");
        extract(type,vi_type);//得到vip型号

        head=createlink_pad();//把pad的头指针给了head
    }while(iftype(head,type)==1);

    cost_pad=search_pad(head,type);

    do
    {
        printf("input pad_area (not 0): ");//板片面积
        scanf("%f",&pad_area);
    }while(pad_area==0);
//pad_area=2;

    head=createlink_kj();
    cost_kj=search_kj(head,vi_type);

    printf("Do you want the 'FaLan'?(y/n)");//法兰
    do
    {
        scanf("%c",&fl);
        fflush(stdin);  
        if(fl=='y')
        {
            head=createlink_fl();
            cost_fl=search_fl(head);
        }
        else if(fl=='n');
        else
        {
            printf("please input right (y/n)\n");
        }
    }while((fl=='y'||fl=='n')==0);

    do
    {
        printf("While one do you want,'BaoZhuang' or 'DiTuo'?(b/d)");//包装 或 底托
        do
        {
            scanf("%c",&bd);
            fflush(stdin);
            if(bd=='b')
            {
                head=createlink_bz();
                cost_bz=search_bz(head,type);
            }
            else if(bd=='d')
            {
                head=createlink_dt();
                if(strcmp(type,"BP250B")==0)
                    cost_dt=search_dt(head,type);
                else
                    cost_dt=search_dt(head,vi_type);
            }
            else
            {
                printf("please input right (b/d)\n");
            }
        }while((bd=='d'||bd=='b')==0);
    }while(cost_bz==1||cost_dt==1);



    cost_hrq = cost_pad*pad_area+cost_kj+cost_fl*4+cost_bz+cost_dt;
    printf("count cost %.2f  %s\n",cost_hrq,type);
}

void view()
{
    node *head;
    char a[3];
    scanf("%s",a);

    //printf("input the strname while you want view \n(pad/kj/fl/bz/dt)\n");

    if(strcmp(a,"pad")==0)
    {
        head=createlink_pad();
        outlink_pad(head);
    }
    else if(strcmp(a,"kj")==0)
    {
        head=createlink_kj();
        outlink_kj(head);
    }
    else if(strcmp(a,"fl")==0)
    {
        head=createlink_fl();
        outlink_fl(head);
    }
    else if(strcmp(a,"bz")==0)
    {
        head=createlink_bz();
        outlink_bz(head);
    }
    else if(strcmp(a,"dt")==0)
    {
        head=createlink_dt();
        outlink_dt(head);
    }
    else
    {
        printf("please input right strname\n");
        view();
    }
    printf("\n");
}

int main()
{
    int i;
    good();
    printf("\nHello,");
    for(;;)
    {
        printf("\n---------------------------------------------------\nWhat do you want to do?\n(input the NUMBER at the beginning at every sentence)\n\n");
        printf("*1.calculate the cost of my hrq.\n*2.view the good table.\n*0.exit\n");
        scanf("%d",&i);
        if(i==1)
            Cost();
        if(i==2)
        {
            printf("input the tablename while you want view \n(pad/kj/fl/bz/dt)\n");
            view();
        }
        if(i==0)
        {
            printf("Goodbye\n");
            return 0;
        }
    }
    system("pause");
    return 0;
}

void extract(char all[],char impart[])//take vip type
{
    int i;
    for(i=0;i<strlen(all);i++)
    {
        if(all[i]>=48&&all[i]<=57)
        {
            if((all[i+1]>=48&&all[i+1]<=57)==0)
            {
                impart[i]=all[i];
                break;
            }
        }
        impart[i]=all[i];
        impart[i+1]='\0';
    }
}

int iftype(node *head,char type[])
{
    node *p = head;
    int i,k,j;
    int in=0;

    for(i=1;p!=NULL;i++)//i=0 , because first chain is none
    {
        if(strcmp(type,p->data)==0)//找型号
        {
            for(j=0;j<k+1;j++)
            {
                p=p->next;
            }
            in=0;//找到了型号就跳出,并返回0告知外部循环结束
            break;
        }
         if(p->next==NULL)
        {
            printf("pad XingHao none\n");
            in=1;
        }
        p=p->next;
    }
    return (in);
}

(2). bar and pad.h


#include<stdio.h>7890
#include<stdlib.h>
#include<memory.h>


typedef struct node_pad{
    char data[20];
    struct node_pad *next;
}node_pad;


//从文件中读取数据存入链表
node_pad *createlink_pad()
{
    node_pad *head =(node_pad*)malloc(sizeof(node_pad));
    char t[20];
    node_pad *p;
    node_pad *q;
    p=q=head;
    FILE * r= fopen("板片及垫片.txt","r");
    if(r==NULL)
    {
        printf("打开文件失败!");
        return NULL;
    }

    while(fscanf(r,"%s",t)!=EOF)
    {
       q= (node_pad*)malloc(sizeof(node_pad));
       strcpy(q->data,t);
       //q->data=t;
       p->next=q;
       p=q;
    }
    p->next=NULL;
    fclose(r);
    //printf("success");
    return head;
}


//输出链表到屏幕和文件output.txt
void outlink_pad(node_pad *head)
{
    //printf("??\n");
   node_pad *p=head->next;
   //FILE *w =fopen("output.txt","w");
   int i=0;
   /*if(w==NULL)
   {
       printf("打开文件失败!");
       return;
   }*/
   while(p)
   {
       //输出链表节点数据到屏幕
       i++;
       if(i%9==1)
       {
           printf("%-10s",p->data);
           //fprintf(w,"%-10s",p->data);
           p=p->next;
       }
       else
       {
           printf("%10s",p->data);
           //输出链表节点数据到文件output.txt
           //fprintf(w,"%10s",p->data);
           p=p->next;
        }②
       if(i%9==0)
       {
           printf("\n");
           //fprintf(w,"\n");
       }
   }
   //fclose(w);
   return;
}


// 查找特定元素数据
float search_pad(node_pad *head,char type[])//总型号
{
    char b[10],a[10];//a是规格,b是型号
    char hang[][20]={"304/0.5","304/0.6","316l/0.6","316L/0.6","TAI/0.5","TAI/0.6","nie","pjdpE/N"};
    node_pad *p = head;
    int i,k,j;
    int in=0;
    float cost_pad=0;

    strcpy(b,type);

    do
    {
        printf("input pad-GuiGe   : ");
        scanf("%s",a);
//strcpy(a,"304/0.6");

        for(i=0;i<(sizeof(hang)/sizeof(hang[0]));i++)
        {
            if(strcmp(a,hang[i])==0)//找规格
            {
                k=i;
                in=0;
                break;
            }
            if(i==(sizeof(hang)/sizeof(hang[0]))-1)
            {
                printf("pad GuiGe none\n");
                in=1;
            }
        }
    }while(in==1);

    for(i=1;p!=NULL;i++)//i=0 , because first chain is none
    {
        if(strcmp(b,p->data)==0)//找型号
        {
            for(j=0;j<k+1;j++)
            {
                p=p->next;
            }
            printf("pad  = %s\n",p->data);
            cost_pad = atof(p->data);
            break;
        }
         if(p->next==NULL)
            printf("pad XingHao none\n");
        p=p->next;
    }
    //printf("%.4f\n",cost);
    return (cost_pad);
}

(3). kuangjia.h

//#ifndef 框架_H_INCLUDED
//#define 框架_H_INCLUDED

#include<stdio.h>
#include<stdlib.h>
#include<memory.h>

typedef struct node_kj {
    char data[20];
    struct node_kj *next;
}node_kj;


//从文件中读取数据存入链表
node_kj *createlink_kj()
{
    node_kj *head =(node_kj*)malloc(sizeof(node_kj));
    char t[20];
    node_kj *p;
    node_kj *q;
    p=q=head;
    FILE * r= fopen("框架.txt","r");
    if(r==NULL)
    {
        printf("打开文件失败!");
        return NULL;
    }

    while(fscanf(r,"%s",t)!=EOF)
    {
       q= (node_kj*)malloc(sizeof(node_kj));
       //if(t[0]!=32)
          strcpy(q->data,t);
       p->next=q;
       p=q;
    }
    p->next=NULL;
    fclose(r);
    return head;
}

void outlink_kj(node_kj *head)
{
    node_kj *p=head->next;
    node_kj *p2;
    char a[20]={0};
    int i=0,j=0,o;
    while(p)
    {
        //输出链表节点数据到屏幕
        i++;
        if(i==3)
            printf("\n             ");
        if(i==9)
            printf("\n");


            if(i<10)
                j=0;

            strcpy(a,p->data);
            //printf("%s",a);
            if(a[0]=='B')
            {
                p2=p->next;
                j=0;
                if(strcmp(p2->data,"/")==0)
                {
                    printf("%-7s",p->data);
                    printf("%s  ",p2->data);
                    p=p2->next;
                    printf("%s\n",p->data);
                }
                else
                {
                    printf("%-13s",p->data);
                    printf("\n");
                }
            }
            //else if(p->data[0]='/');
            else
            {
                printf("%13s",p->data);
            }

            for(o=0;o<20;o++)
                a[o]=0;
            j++;
            //printf("%d.",j);
            if(j==8)
            {
                j=1;
                printf("\n");
            }
            p=p->next;

    }
}

// 查找特定元素数据
float search_kj(node_kj *head,char vi_type[])
{
    char a[10],b[20]="16",c[10]="50-100";//a 型号  b 公斤 c 片数
    char padnum[][10]={"50片","50-100片","100-150片","150-200片","200-300片","300以上"};
    node_kj *p = head,*temp;
    int i,j,k;
    int in=0,ing=0,inn=0,inx=0;
    float cost_kj;

    strcpy(a,vi_type);

    //printf("%d\n",sizeof(padnum)/sizeof(padnum[0]));
    do
    {

    for(i=0;p!=NULL;i++)//i=0 , because first chain is none
    {


        if(strcmp(a,p->data)==0)//找型号
        {
            inx=0;
            temp=p;
            //printf("1  %s\n",p->data);
            do
            {
                do
                {
                    //printf("%s_",p->data);
                    p=temp;//归位
                    printf("input kuanfjia-gongjin(公斤以下)");
                    scanf("%s",b);
                    strcat(b,"公斤以下");
                    while(p!=NULL)
                    {
                        if(strcmp(b,p->data)==0)//找公斤
                        {
                            ing=0;
                            //printf("2  %s\n",p->data);
                            do
                            {
                                printf("input kuanfjia-pianshu(片) ");
                                scanf("%s",c);
                                strcat(c,"片");
                                for(j=0;j<sizeof(padnum)/sizeof(padnum[0]);j++)
                                {
                                    //printf("%d\n",j);
                                    if(strcmp(c,padnum[j])==0)//找片数
                                    {
                                        //printf("3  %s  %d\n",padnum[j],j);
                                        for(k=0;k<j+1;k++)
                                        {
                                            p=p->next;
                                        }
                                        printf("cost of 'kj' = %s\n",p->data);
                                        if(strcmp(p->data,"----")==0)
                                        {
                                            inn=1;
                                            printf("intput again\n");
                                        }
                                        else
                                            inn=0;
                                        cost_kj = atof(p->data);
                                        in=0;
                                        break;//片数
                                    }
                                    if(j==5)
                                    {
                                        printf("KunagJia PianShu none\n");//片数不存在
                                        in=1;
                                    }
                                }
                            }while(in==1);//片数
                                break;//公斤
                        }
                        if(p->next==NULL)
                        {
                            printf("KuangJia GongJin none\n");//公斤不存在
                            ing=1;
                        }
                        p=p->next;
                    }
                }while(ing==1);//公斤
            }while(inn==1);//----
            break;//型号
        }
        if(p->next==NULL)
        {
            printf("KuangJia type none!! input agagin\n");//型号不存在
            inx=1;
        }
        p=p->next;
    }
    }while(inx==1);
    return (cost_kj);
}





//#endif // 框架_H_INCLUDED

(4). falan.h

#include<stdio.h>
#include<stdlib.h>
#include<memory.h>

typedef struct node_fl {
    char data[20];
    struct node_fl *next;
}node_fl;


//从文件中读取数据存入链表
node_fl *createlink_fl()
{
    node_fl *head =(node_fl*)malloc(sizeof(node_fl));
    char t[20];
    node_fl *p;
    node_fl *q;
    p=q=head;
    FILE * r= fopen("法兰.txt","r");
    if(r==NULL)
    {
        printf("打开文件失败!");
        return NULL;
    }

    while(fscanf(r,"%s",t)!=EOF)
    {
       q= (node_fl*)malloc(sizeof(node_fl));
       strcpy(q->data,t);
       //q->data=t;
       p->next=q;
       p=q;
    }
    p->next=NULL;
    fclose(r);
    //printf("success");
    return head;
}


//输出链表到屏幕和文件output.txt
void outlink_fl(node_fl *head)
{
    //printf("??\n");
   node_fl *p=head->next;
   //FILE *w =fopen("output.txt","w");
   int i;
   /*if(w==NULL)
   {
       printf("打开文件失败!");
       return;
   }*/
   for(i=1;p!=NULL;i++,p=p->next)
   {
       //输出链表节点数据到屏幕
       if(i==1)
       {
           printf("%-7s",p->data);
           continue;
       }
       if(i<5&&i>1)
       {
           printf("%17s       ",p->data);
           if(i==4)
           {
               printf("\n");
               i=7;
           }
           continue;
       }
       if(i%7==1)
       {
           printf("%-7s",p->data);
           //fprintf(w,"%-10s",p->data);
           //p=p->next;
       }
       else
       {
           printf("%12s",p->data);
           //输出链表节点数据到文件output.txt
           //fprintf(w,"%10s",p->data);
           //p=p->next;
        }
       if(i%7==0)
       {
           printf("\n");
           //fprintf(w,"\n");
       }
   }
   //fclose(w);
   return;
}


// 查找特定元素数据
float search_fl(node_fl *head)
{
    char a[10]="DN40",b[20]="tangangPN1.6";//a是规格,b是材料
    char hang[][20]={"tangangPN1.0","tangangPN1.6","304PN1.0","304PN1.6","316PN1.0","316PN1.6"};
    node_fl *p = head;
    int i,k,j,inc=0,ing=0;
    float cost_fl;


    do
    {
        printf("input falan-cailiao  : ");
        scanf("%s",b);

        for(i=0;i<(sizeof(hang)/sizeof(hang[0]));i++)
        {
            if(strcmp(b,hang[i])==0)//找材料
            {
                inc=0;
                k=i;
                break;
            }
            if(i==(sizeof(hang)/sizeof(hang[0]))-1)
            {
                printf("FaLan CaiLiao none\n");
                inc=1;
            }

        }
    }while(inc==1);

    do
    {
        p=head;
        printf("input falan-guige  : ");
        scanf("%s",a);
        for(i=0;p!=NULL;i++)//i=0 , because first chain is none
        {
            if(strcmp(a,p->data)==0)//找规格
            {
                ing=0;
                for(j=0;j<k+1;j++)
                {
                    p=p->next;
                }
                printf("The cost of fl : %s\n",p->data);
                cost_fl = atof(p->data);
                break;
            }

            if(p->next==NULL)
                {
                    printf("FaLan GuiGe none\n");
                    ing=1;
                }
            p=p->next;
        }
    }while(ing==1);
    return (cost_fl);
}

(5). pack.h

#include<stdio.h>
#include<stdlib.h>
#include<memory.h>

#define FN(a) for(n=0;n<(a);n++,p=p->next)//链表的指针移动步数

typedef struct node_bz {
    char data[20];
    struct node_bz *next;
}node_bz;


//从文件中读取数据存入链表
node_bz *createlink_bz()
{
    node_bz *head =(node_bz*)malloc(sizeof(node_bz));
    char t[20];
    node_bz *p;
    node_bz *q;
    p=q=head;
    FILE * r= fopen("包装.txt","r");
    if(r==NULL)
    {
        printf("打开文件失败!");
        return NULL;
    }

    while(fscanf(r,"%s",t)!=EOF)
    {
       q= (node_bz*)malloc(sizeof(node_bz));
       //if(t[0]!=32)
          strcpy(q->data,t);
       p->next=q;
       p=q;
    }
    p->next=NULL;
    fclose(r);
    return head;
}

void outlink_bz(node_bz *head)
{
    node_bz *p=head->next;
    int i;
    for(i=1;p!=NULL;i++,p=p->next)
    {
        if(i<8)
        {
            printf("%12s   |",p->data);
            if(i==7)
            {
                printf("\n");
                i=14;
                continue;
            }
        }
        else
        {
            if(i%2==0)
                printf("%7s |",p->data);
            else
            printf("%7s",p->data);
        }
        if(i%14==0)
        {
            printf("\n");
        }

    }
}

// 查找特定元素数据
float search_bz(node_bz *head,char type[10])
{
    char a[10],b[10]="200㎡";
    char num[][10]={"BP50B","BP50M","BP100B","BP100M","BP150B","BP150M","BP200M"};
    node_bz *p = head,*temp;
    int i,j,k,n,inm=0,inz=0;
    int size_num = sizeof(num)/sizeof(num[0]);//半个行的元素数
    float cost_bz;

    strcpy(a,type);
    //printf("%s %s \n",a,b);

    for(j=0;j<size_num;j++)
    {
        if(strcmp(a,num[j])==0)//找型号
            break;
        if(j==size_num-1)
        {
            printf("BaoZhuang type none??!!\n");
            inz=1;
            return (inz);
        }
    }

    FN(size_num*3+j*2+1);//从匹配型号下面积开始
    temp=p;
    do
    {
        p=temp;
        printf("input BaoZuang area(㎡) ");
        scanf("%s",b);
        strcat(b,"㎡");
        for(i=0;p!=NULL;i++)
        {
            if(strcmp(b,p->data)==0)//找面积
            {
                inm=0;
                p=p->next;
                printf("baozhuang  = %s\n",p->data);
                cost_bz = atof(p->data);
                break;//面积
            }

            FN(size_num*2)//一次跳转一行
            {
                if(p->next==NULL)
                {
                    printf("BaoZhuang  area none\n");
                    inm=1;
                    p=p->next;
                    break;
                }
            }
        }
    }while(inm==1);
    return (cost_bz);
}


(6). dituo.h

#include<stdio.h>
#include<stdlib.h>
#include<memory.h>

typedef struct node_dt {
    char data[20];
    struct node_dt *next;
}node_dt;


//从文件中读取数据存入链表
node_dt *createlink_dt()
{
    node_dt *head =(node_dt*)malloc(sizeof(node_dt));
    char t[20];
    node_dt *p;
    node_dt *q;
    p=q=head;
    FILE * r= fopen("底托.txt","r");
    if(r==NULL)
    {
        printf("打开文件失败!");
        return NULL;
    }

    while(fscanf(r,"%s",t)!=EOF)
    {
       q= (node_dt*)malloc(sizeof(node_dt));
       strcpy(q->data,t);
       //q->data=t;
       p->next=q;
       p=q;
    }
    p->next=NULL;
    fclose(r);
    //printf("success");
    return head;
}


//输出链表到屏幕和文件output.txt
void outlink_dt(node_dt *head)
{
   node_dt *p=head->next;
   int i;
   for(i=1;p!=NULL;i++)
   {
        if(i%6==1)
        {
            printf("%-10s",p->data);
        }
        else
        {
            printf("%10s",p->data);
        }
        if(i%6==0)
        {
            printf("\n");
        }
        p=p->next;
   }
   return;
}


// 查找特定元素数据
float search_dt(node_dt *head,char type[])
{
    char b[10]="BP100",a[10]="caogang";//a是材料,b是型号
    char hang[][10]={"BP5","BP100","BP150","BP200","BP250B"};
    node_dt *p = head;
    int i,k,j,inc=0,inx=0;
    int n = sizeof(hang)/sizeof(hang[0]);
    float cost_dt;

    strcpy(b,type);

    do
    {
        p=head;
        printf("input dituo-cailiao  :");
        scanf("%s",a);
        for(i=0;p!=NULL;i++)//i=0 , because first chain is none
        {
            if(strcmp(a,p->data)==0)//找材料
            {
                inc=0;
                for(k=0;k<n;k++)
                {
                    if(strcmp(b,hang[k])==0)//找型号
                    {
                        inx=0;
                        break;
                    }
                    if(k==n-1)
                    {
                        printf("DiTuo type none\n");
                        inx=1;
                        return(inc) ;
                    }
                }

                for(j=0;j<k+1;j++)
                {
                    p=p->next;
                }
                printf("底托 = %s\n",p->data);
                cost_dt = atof(p->data);
                break;
            }
            if(p->next==NULL)
            {
                printf("DiTuo CaiLiao none\n");
                inc=1;
            }

            p=p->next;
    }
    }while(inc==1);
    return  (cost_dt);
}

2.价格表文件
(1). 板片及垫片.txt
板片及垫片

(2). 框架.txt
框架

(3). 法兰.txt
法兰

(4). 包装.txt
包装

(5). 底托.txt
底托

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值