永发信息网

怎么用C++设计商场销售管理系统的程序?

答案:2  悬赏:60  手机版
解决时间 2021-04-06 02:32
  • 提问者网友:鐵馬踏冰河
  • 2021-04-05 16:42
请高手指教下,从哪方面下手?? 配送系统和结帐系统销售管理要解决的问题包括、退货单、现金销售、返库单、车辆平衡表;结帐系统包括:销售开票、商场付款、零售开票、其他收款。等,配送系统包括送货单
最佳答案
  • 五星知识达人网友:上分大魔王
  • 2021-04-05 16:55
构造
4你的先去了解一下你所编的商场销售管理系统主要是作什么的在了解一下用户想用这个做什么,完成什么样的功能主要你可以从这几个方面下手
1.细化
3.初始
2
全部回答
  • 1楼网友:执傲
  • 2021-04-05 17:17
//为了顺便练习一下使用链表结构,所以用链表结构实现。
// -----by kuaidh00--------2008/01/08-------------
//****************************************************
#include <iostream>
#include <string>
#include <iomanip>
#include <stdio.h>


using namespace std;

struct sale
{
 //数据域。
 string m_code;
 string m_name;
 float m_price;
 unsigned int m_quantity;
 //指针域。
 struct sale* next;
};

typedef struct sale node;//取外别名,node.
typedef node* link;//取个别名,link.

//创建链表。
link create(link head)
{
 //-----初始化头节点 head-------
 head=(link)new node;//每次动态分配一个node内存大小。
 head->m_code="";
 head->m_name="";
 head->m_price=0.0;
 head->m_quantity=0;
 head->next=null;

 //-----
 link ptr;//定义一个用来运算的指针 ptr。 
 ptr=head;//指到首节点。
 link dnode;//定义数据节点,用来存放数据。
 char goon;
 do
 {
 cout<<"商品信息录入! "<<endl;
 string code,name;
 float price;
 unsigned int quantity;
 cout<<"输入代码:"<<endl;
 cin>>code;
 cout<<"输入名称:"<<endl;
 cin>>name;
 cout<<"输入价格:"<<endl;
 cin>>price;
 while(cin.fail())
 {
 cout<<"请输入正确的格式:"<<endl;
 cin.clear();
 fflush(stdin);
 cin>>price;
 }
 cout<<"输入数量:"<<endl;
 cin>>quantity;
 while(cin.fail())
 {
 cout<<"请输入正确的格式:"<<endl;
 cin.clear();
 fflush(stdin);
 cin>>quantity;
 }
 //----数据域-----
 dnode=(link)new node;//每次动态分配一个node内存大小。
 dnode->m_code=code;
 dnode->m_name=name;
 dnode->m_price=price;
 dnode->m_quantity=quantity;
 //----指针域-----
 dnode->next=null;//作为尾节点加入。
 ptr->next=dnode;//链入链表中。
 ptr=dnode;//使新节点成为下一次的前驱。
 cout<<"商品信息录入成功! 是否继续录入?(y/n) ";
 cin>>goon;

 }while(goon=='y'||goon=='y');
 return head;
}

//释放链表。
void release(link head)
{
 link ptr;
 while(head!=null)
 {
 ptr=head;
 head=head->next;
 delete ptr;
 }
}

//查询。
link search(link head,string& code)
{
 link ptr;
 //link front;
 ptr=head;//定义一个用于操作的指针ptr。
 //ptr=fornt->next;
 while(ptr!=null)
 {
 if(ptr->m_code==code)
 return ptr;
 else
 ptr=ptr->next;
 }
 cout<<"无此商品!"<<endl;
 return ptr;//此时的ptr为null了。
}

//打印链表。
void display(link head)
{
 link ptr;
 ptr=head->next;//,不要头节点,只输出数据节点。
 cout<<"==========================================================="<<endl;
 cout<<"===============所有商品信息清单============================"<<endl;
 cout<<"==========================================================="<<endl;
 cout<<"货品代码=======货品名称======货品价格======货品数量===="<<endl;
 while(ptr!=null)
 {
 cout<<setw(15)<<left<<ptr->m_code
 <<setw(15)<<left<<ptr->m_name
 <<setw(15)<<left<<ptr->m_price
 <<setw(15)<<left<<ptr->m_quantity<<endl;
 ptr=ptr->next;
 }
}
void display_one(link head,string& code,unsigned quantity)
{
 link ptr;
 ptr=search(head,code);//,不要头节点,只输出数据节点。
 cout<<"货品代码=======货品名称======货品价格======货品数量======小计(元)===="<<endl;
 cout<<setw(15)<<left<<ptr->m_code
 <<setw(15)<<left<<ptr->m_name
 <<setw(15)<<left<<ptr->m_price
 <<setw(15)<<left<<quantity
 <<setw(15)<<left<<quantity*ptr->m_price<<endl;

}


//单个商品小结。
float checkout(link head,string& code,unsigned quantity)
{
 link ptr;
 float sum(0); 
 ptr=search(head,code);
 sum=(ptr->m_price*quantity);
 return sum;
}

//总结帐。
void total(link head)
{
 link ptr;
 ptr=head;
 float sum(0);
 float factly;
 char goon;
 while(1)
 {
 cout<<"要结束商品买入请按\'n\',其它任意键表示继续买入! "<<endl;
 cin>>goon;
 if(goon=='n'||goon=='n')
 break;
 else
 {
 string code;
 unsigned int quantity;
 cout<<"输入要购买的商品代码:"<<endl;
 cin>>code;
 cout<<"输入要购买的数量:"<<endl;
 cin>>quantity;
 sum+=checkout(ptr,code,quantity);
 cout<<"你购买的商品为:"<<endl;
 display_one(ptr,code,quantity);
 }
 }
 cout<<"----------------------------------------------------"<<endl;
 cout<<"你应该付 "<<sum<<"元!"<<endl;
 cout<<"你实际付(元): ";
 cin>>factly;
 cout<<"应该找回你 "<<factly-sum<<"元!"<<endl;//找零。
}


int main()
{
 //---------菜单选项----------------
 link head=null;
 //head=create(head);

 int loop=1;
 while(loop)
 {
 cout<<"***************************************************"<<endl;
 cout<<"*---------------------菜单选项--------------------*"<<endl;
 cout<<"*-------------------------------------------------*"<<endl;
 cout<<"* 1.输入数据 2.买入商品 3.显示数据 0.退出系统 *"<<endl;
 cout<<"***************************************************"<<endl;
 int menu;
 cin>>menu;
 if(cin.fail())
 {
 cout<<"请按菜单对应的数字选择合适的操作,谢谢合作!"<<endl;
 cin.clear();
 fflush(stdin);
 cin>>menu;
 }
 switch(menu)
 {
 case 0:
 cout<<"已退出系统!"<<endl;
 loop=0;
 break;
 case 1:
 head=create(head);
 break;
 case 2:
 total(head);
 break;
 case 3:
 display(head);
 break;
 }//switch(menu)
 }//while(loop)

 //display(head);
 //total(head);
 release(head);
 return 0;
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯