当前位置:编程学习 > C/C++ >>

哪位大哥能帮我编程啊!!!C++的

帮我设计一个“员工信息管理系统” 代码一定要写详细一点的 谢谢啦!! 写得好有加分哦(⊙o⊙)…
答案:# include <iostream>  

# include <fstream>

# include <string>

# include <iomanip>

# include <stdlib.h>
using namespace std;
struct worker_inf
{int month; //月份
int code; //工人编号
string name; //姓名
float get[4]; //基本工资,津贴,房帖,交通补贴
float pay[4]; //房租,储蓄,交通费,会费
float tax; //个人所得税
float theory_num; //应发书
float reduce_num; //应扣数
float practice_num; //实发数
worker_inf *next;
};
class worker //定义职工类
{
private:
worker_inf *head;
void print(worker_inf *); //输出一条指定职工的工资记录,并返回该记录的指针
worker_inf *find(int); //查找条例条件的记录,并返回该记录的指针
public:
worker(){head=NULL;}
worker_inf *get_head(){return head;}
int listcount(); //统计当前链表的记录总数,并返回一个整数
void additem(int month,int code,string name,float get[4],float pay[4]); //添加一条工资记录表尾
void removeitem(int); //删除一条指定职工的工资记录
int menu(); //修改某职工工资的菜单
void changemonth(); //修改月份
void changeitem(int); //修改职工的工资信息
void list(); //输出当月全体职工的工资信息
void search(int); //输出指定编号职工的工资信息
float tax_num(); //计算职工个人所得税
float theorynumber(); //计算应发工资
float reducenumber(); //计算应扣工资
float practicenumber(); //计算实发工资
};
int worker::listcount() //统计当前链表数,并返回一个整数
{
if(!head)return 0;
worker_inf *p=head;
int n=0;
while(p)
{n++;p=p->next;}
return n;
}
void worker::additem(int month,int code,string name,float get[4],float pay[4]) //添加一条工资记录到表尾
{
if(!head)
{
head=new worker_inf;
for(int i=0;i<4;i++)
{
head->get[i]=get[i];
head->pay[i]=pay[i];
}
head->code=code;
head->month=month;
head->name=name;
head->next=NULL;
return;
}
worker_inf *t=head;
while(t && t->code!=code)
t=t->next;
if(t)
{
cout<<"操作失败:编号为"<<code<<"的记录已经存在!"<<endl;
return;
}
worker_inf *p=head;
while(p->next)p=p->next;
worker_inf *p1=new worker_inf;
p1->code=code;
for(int i=0;i<4;i++)
{
p1->get[i]=get[i];
p1->pay[i]=pay[i];
}
p1->code=code;
p1->month=month;
p1->name=name;
p1->next=NULL;
p->next=p1;
return;
}
void worker::removeitem(int code) //删除一条指定职工的工资记录
{
worker_inf *t=find(code);
if(!t)return;
worker_inf *p=head;//如果要删除的记录位于表头
if(head==t)
{
head=head->next;
delete p;
cout<<"成功删除编号为"<<code<<"的记录!"<<endl<<endl;
return;
}
while(p->next!=t)p=p->next;
worker_inf *p1=p->next;
p->next=p1->next;
delete p1;
cout<<"成功删除编号为"<<code<<"的记录!"<<endl<<endl;
return;
}
int worker::menu() //修改某一职工信息的菜单
{
int select=-1;
cout<<"\t\t\t\t\t\t**************修改菜单**************"<<endl<<endl;
cout<<"1.基本工资"<<endl<<endl;
cout<<"2.津贴"<<endl<<endl;
cout<<"3.房帖"<<endl<<endl;
cout<<"4.交通补贴"<<endl<<endl;
cout<<"5.房租"<<endl<<endl;
cout<<"6.储蓄"<<endl<<endl;
cout<<"7.交通费"<<endl<<endl;
cout<<"8.会费"<<endl<<endl;
cout<<"0.退出修改系统"<<endl<<endl;
cout<<"[请选择(输入相应数字)]:";
cin>>select;
if(select<0||select>9)
{
cout<<"对不起您输入错误!请重新输入【0-9】:"<<endl;
cin>>select;
}
return select;
}
int menu();
void worker::changeitem(int code) //修改某职工部分工资信息
{
worker_inf *p=find(code);
if(!p){cout<<"不存在职工编号为"<<code<<"的职工工资信息"<<endl;return;}
int select;
while(1)
{
float m;
select=menu();
if(select==0){system("cls");break;}
cout<<"请输入修改后的值";
cin>>m;
int n;
if(select<=4){
n=select-1;
p->get[n]=m;}
else{
n=select-5;
p->pay[n]=m;}
tax_num();
theorynumber();
reducenumber();
practicenumber();
cout<<"修改成功"<<endl;
}
}
void worker::changemonth() //修改月份
{
worker_inf *p=head;
while(p)
{
if(p->month==12)p->month=1;
else
p->month++;
p=p->next;
}
}
void worker::print(worker_inf *p)//输出worker_inf制定的记录
{
cout.precision(0);
cout<<p->month<<" ";
cout<<p->code<<" ";
cout<<p->name<<"\t";
for(int i=0;i<4;i++)
{cout<<setiosflags(ios::fixed)<<p->get[i]<<"\t";}
for(int j=0;j<4;j++)
{cout<<p->pay[j]<<"\t";}
cout<<p->tax<<"\t";
cout<<p->theory_num<<"\t";
cout<<p->reduce_num<<"\t";
cout<<p->practice_num<<endl<<endl;
return;
}
void worker::list() //列出当前链表中的所有记录
{
if(listcount==0)
{
cout<<"错误:当前的列表为空!"<<endl;
return;
}
worker_inf *p=head;
cout<<"共有记录:"<<listcount()<<endl;
cout<<"月份\t编号\t姓名\t基本工资\t津贴\t房帖\t交通补贴\t房租\t储蓄\t交通费\t会费\t个人所得税\t应发工资\t应扣工资\t实际工资"<<endl;
while(p)
{
print(p);
p=p->next;
}
cout<<endl;
return;
}
void worker::search(int code) //在当前链表查找指定记录并输出
{
cout<<"searching....."<<endl;
worker_inf *p=find(code);
if(p)
{
cout<<"月份\t编号\t姓名\t基本工资\t津贴\t房帖\t交通补贴\t房租\t储蓄\t交通费\t会费\t个人所得税\t应发工资\t应扣工资\t实际工资"<<endl;
print(p);
}
cout<<endl;
}
worker_inf *worker::find(int code) //查找条例条件的记录,并返回该指针
{
if(listcount==0)
{
cout<<"错误:当前列表为空!"<<endl;
return NULL;
}
worker_inf *p=head;
while(p)
{
if(p->code==code)break;
p=p->next;
}
if(!p)
{
cout<<"错误:找不到该记录!\n";
return NULL;
}
return p;
}
float worker::theorynumber() //计算应发数
{
int i;
if(listcount()==0)
{
cout<<"错误:当前的列表为空!"<<endl;
return -1;
}
float sum;
worker_inf *p=head;
while(p)
{
sum=0;
for(i=0;i<4;i++)
sum+=p->get[i];
p->theory_num=sum;
p=p->next;
}
return 0;
}
float worker::tax_num() //计算个人所得税
{
if(listcount==0)
{
cout<<"错误:当前的列表为空!"<<endl;
return -1;
}
worker_inf *p=head;
while(p)
{
float s;
s=p->theory_num;
if(s<=800)
p->theory_num=0;
else if(s<=2000) p->theory_num=(s-800)*0.05;
else if(s<=5000)
p->theory_num=(s-2000)*0.1+60;
else p->theory_num=(s-5000)*0.2+360;
p=p->next;
}
return 0;
}
float worker::reducenumber() //计算应扣数
{
int i;
if(listcount==0)
{
cout<<"错误:当前的列表为空!"<<endl;
}
float sum;
worker_inf *p=head;
while(p)
{
sum=0;
for(i=0;i<4;i++)
sum+=p->pay[i];
p->reduce_num=p->tax+sum;
p=p->next;
}
return 0;
}
float worker::practicenumber() //计算实发数
{
if(listcount()==0)
{
cout<<"错误:当前的列表为空!"<<endl;
return -1;
}
worker_inf *p=head;
while(p)
{
float a,b;
a=p-&g

上一个:C++修改txt文件里数据 历史最高分悬赏
下一个:帮我看看这个C++程序是什么错误。

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,