MyException - 我的异常网
当前位置:我的异常网» C++ » 求人事管理管理系统代码,该怎么解决

求人事管理管理系统代码,该怎么解决(2)

www.MyException.Cn  网友分享于:2013-02-16  浏览:5次

}
double Hourly_Worker::getpay()
{
return Sumsalary=salary*hour;
}

class Comm_Worker :public Person
{
double salary,profit;
int month;
public:
Comm_Worker();
void Input();
virtual double getpay();
};
Comm_Worker::Comm_Worker()
{
job="Comm_Worker";
salary=1800;
profit=20000;
month=0;
}
void Comm_Worker::Input()
{
InputPerson();
cout<<"Please input Salary:"<<endl;
cin>>salary;
cout<<"plaese input Profit:"<<endl;
cin>>profit;
cout<<"plaese input Month:"<<endl;
cin>>month;
}
double Comm_Worker::getpay()
{
return Sumsalary=month*(salary+profit*0.05) ;
}

class report 
{
public:
void add();
void search();
void del();
void print();
};
void report::print()
{
ifstream ioFile("EmployeeInfo.txt",ios::in);
if(ioFile.fail())
{
perror("ioFile");
cout<<"Cannot open the file!\n";
return ;
}
string id,Name,Sex,Job;
int Age;
double Salary;
ioFile>>id;
while(ioFile.peek()!=EOF)
{
ioFile>>Name>>Job>>Age>>Sex>>Salary;
cout<<id<<"\t   "<<Name<<"\t"<<Job<<"\t"<<Age<<"\t"<<Sex<<"\t"<<Salary<<endl;
ioFile>>id;
}
ioFile.close();
}
void report::add()
{
int choice1;
char ch;
cout<<"要添加员工的信息吗(y):";
cin>>ch;
Boss p1;
Employee p2;
Hourly_Worker p3;
Comm_Worker p4;
while(ch=='y')
{
ofstream ioFile("EmployeeInfo.txt",ios::out
------解决方案--------------------
ios::app);
if(!ioFile)
{
cout<<"Can not open the file!"<<endl;
return ;
}
cout<<"请选择类型:"<<endl;
cout<<"----------------------------"<<endl;
cout<<"1 BOss"<<setw(6)<<"│"<<" 2 Employee"<<setw(6)<<"│"<<"3 Hourly_Worker"<<
setw(6)<<"│"<<"4 Comm_Worker"<<"│"<<endl;
cout<<"----------------------------"<<endl;
cin>>choice1;
switch(choice1)
{
case 1:

p1.Input();
ioFile<<p1;
break;
case 2:
p2.Input();
ioFile<<p2;
break;
case 3:
p3.Input();
ioFile<<p3;
break;
case 4:
p4.Input();
ioFile<<p4;
break;
}
ioFile.close();
cout<<"继续添加员工信息吗?(y/n):";
cin>>ch;
}
cout<<"添加成功......"<<endl;
}
void report::search()
{
string id,Name,Sex,Job;
int Age;
double Salary;
string number;
int ok=0;
cout<<"请输入要查询的工作号:"<<endl;
cin>>number;
ifstream ioFile("EmployeeInfo.txt",ios::in);
if(ioFile.fail())
{
perror("ioFile");
cout<<"Cannot open the file!\n";
return ;
}
cout<<"正在寻找,请等待……"<<endl;
ioFile>>id;
while(ioFile.peek()!=EOF)
{
if(id==number)
{
ioFile>>Name>>Job>>Age>>Sex>>Salary;

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有