帮帮我啊!!!老师让编的作业,一堆错误!!头都晕了

wj_yhl 2006-07-05 03:29:56
//data.h


#ifdef DATA
#define DATA
Engineer engineer[5];
Manager manager[4];
Salesman salesman[10];
SalesManager salesmanager[5];
int id=0;
int age=0;
int time=0;
int mid=0;
long mark=0;
char sex='m';
char name[20]="no name!";
long money=0;
#endif

//myclass.h
#ifndef MY
#define MY
class Employee
{
protected:
int ID;
int age;
char sex;
char name[20];
public:
virtual double Salary();
void Set(int,int,char,char*);
int Outid();
int Outage();
char Outsex();
char* Outname();
};
class Engineer : public Employee
{
protected:
int workTime;
public:
virtual double Salary();
void Set(int,int,int,char,char*);
int Outtime();
};
class Manager : public Employee
{
public:
virtual double Salary();
};
class Salesman : public Employee
{
protected:
long mark;
int mID;
public:
virtual double Salary();
void Set(int,int,int,long,char,char*);
long Outmark();
int Outmid();
};
class SalesManager : public Manager
{
public:
virtual double Salary();
long Outmoney();
protected:
long money;
};
#endif

//main.cpp
#include"myclass.h"
#include<iostream.h>
#include<iomanip.h>
#include<string.h>
#include"data.h"
void manu1();
void manu2();
void manu3();
void manu4();
void manu5();
int select;
void main()
{
loop:
cout<<"  ★★小型公司工资管理系统★★"<<endl;
cout<<"   ┌──────────────┐"<<endl;
cout<<" │ 请选择您所需的操作: │"<<endl;
cout<<" │ 数据输入:1,并按回车键 │"<<endl;
cout<<" │ 数据统计:2,并按回车键 │"<<endl;
cout<<" │ 数据打印:3,并按回车键 │"<<endl;
cout<<" │ 数据备份:4,并按回车键 │"<<endl;
cout<<" │ 退出系统:5,并按回车键 │"<<endl;
cout<<" └──────────────┘"<<endl;
cout<<" 请选择一个操作:"<<endl;
cin>>select;
switch(select)
{
case 1:manu1();goto loop;
case 2:manu2();goto loop;
case 3:manu3();goto loop;
case 4:manu4();goto loop;
case 5:manu5();goto loop;
default : cout<<"错误!请输入合适的数据!"<<endl; goto loop;
}
}

//myclass.cpp
#include"myclass.h"
#include<iostream.h>
#include<string.h>
#include"data.h"
double Employee::Salary()
{
return 0;
}
void Employee::Set(int id,int ag,char se,char*na)
{
ID=id;
age=ag;
sex=se;
strcpy(name,na);
name[19]='\0';
}
int Employee::Outid()
{
return ID;
}
int Employee::Outage()
{
return age;
}
char Employee::Outsex()
{
return sex;
}
char* Employee::Outname()
{
return name;
}
double Engineer::Salary()
{
return 100*workTime;
}
void Engineer::Set(int id,int ag,int wo,char se,char*na)
{
Employee::Set(id,ag,se,na);
workTime=wo;
}
int Engineer::Outtime()
{
return workTime;
}
double Manager::Salary()
{
return 8000;
}
double Salesman::Salary()
{
return mark*4.0/100;
}
void Salesman::Set(int id,int ag,int mid,long ma,char se,char*na)
{
Employee::Set(id,ag,se,na);
mID=mid;
mark=ma;
}
long Salesman::Outmark()
{
return mark;
}
int Salesman::Outmid()
{
return mID;
}
double SalesManager::Salary()
{
return money*0.5/100+5000;
}
long SalesManager::Outmoney()
{
money=0;
for(int i=0;i<10;i++)
{
if(salesman[i].Outmid()==ID)
money+=salesman[i].Outmark();
}
return money;
}
...全文
266 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
p1s 2006-07-06
  • 打赏
  • 举报
回复
先修正语法错误。貌似你一下子写得太多了。
双杯献酒 2006-07-06
  • 打赏
  • 举报
回复
#ifdef DATA
#define DATA

改成
#ifndef DATA
#define DATA
阿浪 2006-07-06
  • 打赏
  • 举报
回复
我的妈.....谁有空呀.
jixingzhong 2006-07-05
  • 打赏
  • 举报
回复
慢慢改吧 ...

我也晕了 ~
wj_yhl 2006-07-05
  • 打赏
  • 举报
回复
程序很长,在这里先谢谢了
感激不尽哪
wj_yhl 2006-07-05
  • 打赏
  • 举报
回复
//maun4.cpp
#include<fstream.h>
#include<iostream.h>
#include"data.h"
void manu4()
{
fstream file;
file.open("d:\\",ios::in|ios::out|ios::app|ios::trunc,0);
for(int i=0;i<5;i++)
{
file<<"技术员"<<endl;
file<<"职工号:"<<engineer[i].Outid()
<<"   姓名:"<<engineer[i].Outname()
<<"   性别:"<<engineer[i].Outsex()
<<"   年龄:"<<engineer[i].Outage()
<<"   工资:"<<engineer[i].Salary()
<<" 工作时间:"<<engineer[i].Outtime()
<<endl;
}
cout<<"___________________________________"<<endl;
for(int k=0;k<4;k++)
{
file<<"经理"<<endl;
file<<"职工号:"<<manager[k].Outid()
<<"   姓名:"<<manager[k].Outname()
<<"   性别:"<<manager[k].Outsex()
<<"   年龄:"<<manager[k].Outage()
<<"   工资:"<<manager[k].Salary()
<<endl;
}
cout<<"___________________________________"<<endl;
for(i=0;i<10;i++)
{
file<<"销售员"<<endl;
file<<"职工号:"<<salesman[i].Outid()
<<"   姓名:"<<salesman[i].Outname()
<<"   性别:"<<salesman[i].Outsex()
<<"   年龄:"<<salesman[i].Outage()
<<"   工资:"<<salesman[i].Salary()
<<" 销售额:"<<salesman[i].Outmark()
<<" 所属销售经理的编号:"<<salesman[i].Outmid()
<<endl;
}
cout<<"___________________________________"<<endl;
for(i=0;i<5;i++)
{
file<<"销售经理"<<endl;
file<<"职工号:"<<engineer[i].Outid()
<<"   姓名:"<<engineer[i].Outname()
<<"   性别:"<<engineer[i].Outsex()
<<"   年龄:"<<engineer[i].Outage()
<<"   工资:"<<engineer[i].Salary()
<<endl;
}
file.close();
}

//manu5.cpp
#include<stdlib.h>
void manu5()
{
exit(1);
}
wj_yhl 2006-07-05
  • 打赏
  • 举报
回复
//manu1.cpp
#include<iostream.h>
#include"data.h"
#include<string.h>
#include"myclass.h"
void manu1()
{
for(int i=0;i<5;i++)
{
id=0;
age=0;
time=0;
//name[20]="no name!";
sex='m';
cout<<"技术员的编号:";
cin>>id;
cout<<"其姓名:";
cin.getline(name,19);
cout<<"性别(m/w):";
cin>>sex;
cout<<"年龄:";
cin>>age;
cout<<"工作时间:";
cin>>time;
engineer[i].Set(id,age,time,sex,name);
}
cout<<"______________________________\n";
for(i=0;i<4;i++)
{
id=0;
age=0;
//name[20]="no name!";
sex='m';
cout<<"经理的编号:";
cin>>id;
cout<<"其姓名:";
cin.getline(name,19);
cout<<"性别(m/w):";
cin>>sex;
cout<<"年龄:";
cin>>age;
manager[i].Set(id,age,sex,name);
}
cout<<"______________________________\n";
for(i=0;i<10;i++)
{
id=0;
age=0;
//name[20]="no name!";
sex='m';
mark=0;
mid=0;
cout<<"销售员的编号:";
cin>>id;
cout<<"其姓名:";
cin.getline(name,19);
cout<<"性别(m/w):";
cin>>sex;
cout<<"年龄:";
cin>>age;
cout<<"销售额:";
cin>>mark;
cout<<"所属销售经理的编号:";
cin>>mid;
salesman[i].Set(id,age,mid,mark,sex,name);
}
cout<<"______________________________\n";
for(i=0;i<5;i++)
{
id=0;
age=0;
//name[20]="no name!";
sex='m';
cout<<"销售经理的编号:";
cin>>id;
cout<<"其姓名:";
cin.getline(name,19);
cout<<"性别(m/w):";
cin>>sex;
cout<<"年龄:";
cin>>age;
salesmanager[i].Set(id,age,sex,name);
}
cout<<"______________________________\n";
}


//manu2.cpp
#include<iostream.h>
#include<iomanip.h>
#include"myclass.h"
#include"data.h"
void manu2()
{
for(int j=0;j<10;j++)
{
cout<<"职工号为"<<salesmanager[j].Outid()<<"的销售经理"<<salesmanager[j].Outname()<<"下属销售员业绩为:"<<endl;
cout<<"┌──────┬──────┬──────┐\n";
cout<<"│职工号   │姓名    │销售额   │\n";
for(int i=0;i<10;i++)
{
if(salesman[i].Outmid()==salesmanager[j].Outid())
{
cout<<"├──────┽──────┽──────┤\n";
cout<<"│"<<setw(12)<<salesman[i].Outid()<<"│"<<setw(12)<<salesman[i].Outname()<<"│"<<setw(12)<<salesman[i].Outmark()<<"│"<<endl;
}
}
cout<<"├──────┴───┬──┴──────┤\n";
cout<<"│销售额总计:    │"<<setw(12)<<salesmanager[j].Outmoney()<<"│"<<endl;
cout<<"└──────────┴─────────┙"<<endl;
}
cout<<"销售经理按工资排序为:"<<endl;
cout<<"┌──────┬──────┬──────┬──────┬──────┐"<<endl;
cout<<"│职工号   │姓名    │性别    │年龄    │工资    │"<<endl;
int i,q,temp;
for(i=0;i<4;i++)
{
q=i;
for(j=i+1;j<5;j++)
if(salesmanager[i].Outmoney()<salesmanager[j].Outmoney())
{
temp=q;
q=j;
j=temp;
}
}
for(int k=0;k<5;k++)
{
cout<<"├──────┽──────┽──────┽──────┽──────┤"<<endl;
cout<<"│"<<setw(12)<<salesmanager[k].Outid()
<<"│"<<setw(12)<<salesmanager[k].Outname()
<<"│"<<setw(12)<<salesmanager[k].Outsex()
<<"│"<<setw(12)<<salesmanager[k].Outage()
<<"│"<<setw(12)<<salesmanager[k].Salary()<<"│"<<endl;
}
cout<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
}

//manu3.cpp
#include<iostream.h>
#include<iomanip.h>
#include"data.h"
void manu3()
{
cout<<"请等待......"<<endl;
cout<<"职工基本情况一览表如下\n";
cout<<"技术员"<<endl;
cout<<endl;
cout<<"┌──────┬──────┬──────┬──────┬──────┐"<<endl;
cout<<"│职工号   │姓名    │性别    │年龄    │工资    │"<<endl;
for(int i=0;i<5;i++)
{
cout<<"├──────┽──────┽──────┽──────┽──────┤"<<endl;
cout<<"│"<<setw(12)<<engineer[i].Outid()
<<"│"<<setw(12)<<engineer[i].Outname()
<<"│"<<setw(12)<<engineer[i].Outsex()
<<"│"<<setw(12)<<engineer[i].Outage()
<<"│"<<setw(12)<<engineer[i].Salary()<<"│"<<endl;
}
cout<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
cout<<endl;
cout<<"______________________________________"<<endl;
cout<<"经理"<<endl;
cout<<endl;
cout<<"┌──────┬──────┬──────┬──────┬──────┐"<<endl;
cout<<"│职工号   │姓名    │性别    │年龄    │工资    │"<<endl;
for(i=0;i<4;i++)
{
cout<<"├──────┽──────┽──────┽──────┽──────┤"<<endl;
cout<<"│"<<setw(12)<<manager[i].Outid()
<<"│"<<setw(12)<<manager[i].Outname()
<<"│"<<setw(12)<<manager[i].Outsex()
<<"│"<<setw(12)<<manager[i].Outage()
<<"│"<<setw(12)<<manager[i].Salary()<<"│"<<endl;
}
cout<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
cout<<endl;
cout<<"______________________________________"<<endl;
cout<<"销售经理"<<endl;
cout<<endl;
cout<<"┌──────┬──────┬──────┬──────┬──────┐"<<endl;
cout<<"│职工号   │姓名    │性别    │年龄    │工资    │"<<endl;
for(i=0;i<5;i++)
{
cout<<"├──────┽──────┽──────┽──────┽──────┤"<<endl;
cout<<"│"<<setw(12)<<salesmanager[i].Outid()
<<"│"<<setw(12)<<salesmanager[i].Outname()
<<"│"<<setw(12)<<salesmanager[i].Outsex()
<<"│"<<setw(12)<<salesmanager[i].Outage()
<<"│"<<setw(12)<<salesmanager[i].Salary()<<"│"<<endl;
}
cout<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
cout<<endl;
cout<<"______________________________________"<<endl;
cout<<"销售员"<<endl;
cout<<endl;
cout<<"┌──────┬──────┬──────┬──────┬──────┬──────────┐"<<endl;
cout<<"│职工号   │姓名    │性别    │年龄    │工资    │所属销售经理的编号 │"<<endl;
for(i=0;i<5;i++)
{
cout<<"├──────┽──────┽──────┽──────┽──────┤"<<endl;
cout<<"│"<<setw(12)<<salesman[i].Outid()
<<"│"<<setw(12)<<salesman[i].Outname()
<<"│"<<setw(12)<<salesman[i].Outsex()
<<"│"<<setw(12)<<salesman[i].Outage()
<<"│"<<setw(12)<<salesman[i].Salary()
<<"│"<<setw(20)<<salesman[i].Outmid()<<"│"<<endl;
}
cout<<"└──────┴──────┴──────┴──────┴──────┘"<<endl;
cout<<endl;
cout<<"______________________________________"<<endl;
}

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧