怎么才能把输出改成像表格那样?
希望高手们帮帮我这个新手,在此先谢谢大家!!!!!#include <iostream.h>
#include <string.h>
class Teacher
{
private:
char id[20];//员工号
char name[20];//员工姓名
int grade;//员工行政级别
int basic;//基本工资
int station;//岗位工资
int life;//生活补贴
int leave;//请假天数
int teachnum;//授课课时
int teachsalary;//课时工资
int award;//奖励
float origsalary;//应发工资
float tax;//个人所得税
float realssalary;//实发工资
public:/*需要按循序排列*/
Teacher();
Teacher(char *id,char *name,int grade,int leave,int teachnum,int award);
void setid(char *id);
void setname(char *name);
void setgrade(int grade);
void setbasic(int basic);
void calstation();
void setlife(int life);
void setleave(int leave);
void setteachnum(int teachnum);
void calteachsalary();
void setaward(int award);
void calorigsalary();
void caltax();
void calrealssalary();
void setprintbill();
void calprintbill();
};
#include <iostream.h>
#include <string.h>
#include "TeacherSalary.h"
Teacher::Teacher()
{
strcpy(id,"0");
strcpy(name,"");
grade=1;
basic=500;
station=0;
life=150;
leave=0;
teachnum=0;
teachsalary=0;
award=0;
origsalary=0.0;
tax=0.0;
realssalary=0.0;
}
Teacher::Teacher(char *id,char *name,int grade,int leave,int teachnum,int award)
{
strcpy(this->id,id);
strcpy(this->name,name);
this->grade=grade;
this->basic=basic;
this->life=life;
this->leave=leave;
this->teachnum=teachnum;
this->award=award;
}
void Teacher::setid(char *id)
{
strcpy(this->id,id);
}
void Teacher::setname(char *name)
{
strcpy(this->name,name);
}
void Teacher::setgrade(int grade)
{
this->grade=grade;
}
void Teacher::setbasic(int basic)
{
this->basic=500;
}
void Teacher::calstation()
{
if(this->grade>=1&&this->grade<=3)
{
station=500;
}
else if(this->grade>=4 && this->grade<=6)
{
station=700;
}
else if(this->grade>=7&&this->grade<=9)
{
station=1000;
}
}
void Teacher::setlife(int life)
{
this->life=150;
}
void Teacher::setleave(int leave)
{
this->leave=leave;
}
void Teacher::setteachnum(int teachnum)
{
this->teachnum=teachnum;
}
void Teacher::calteachsalary()
{
this->teachsalary =this->teachnum * (15+ this->grade * 3);
}
void Teacher::setaward(int award)
{
this->award=award;
}
void Teacher::calorigsalary()
{
this->origsalary = ( this->basic + this->station ) / 22.0f * ( 22.0f - this->leave ) + this->life + this->teachsalary + this->award;
}
void Teacher::caltax()
{
this->tax = ( this->origsalary - 2000.0f ) * 0.09f;
}
void Teacher::calrealssalary()
{
this->realssalary= this->origsalary - this->tax;
}
void Teacher::calprintbill()
{
cout<<"员工号"<<this->id<<endl;
cout<<"员工姓名"<<this->name<<endl;
cout<<"员工行政级别"<<this->grade<<endl;
cout<<"基本工资"<<this->basic<<endl;
cout<<"生活补贴"<<this->life<<endl;
cout<<"请假天数"<<this->leave<<endl;
cout<<"授课课时"<<this->teachnum<<endl;
cout<<"课时工资"<<this->teachsalary<<endl;
cout<<"奖励"<<this->award<<endl;
cout<<"应发工资"<<this->origsalary<<endl;
cout<<"个人所得税"<<this->tax<<endl;
cout<<"实发工资"<<this->realssalary<<endl;
}
#include <iostream.h>
#include <string.h>
#include "TeacherSalary.h"
void main()
{
char id[20],name[20];
int grade,leave,teachnum,award;
cout<<"员工号"<<endl;
cin>>id;
cout<<"员工姓名"<<endl;
cin>>name;
cout<<"员工行政级别"<<endl;
cin>>grade;
cout<<"请假天数"<<endl;
cin>>leave;
cout<<"授课课时"<<endl;
cin>>teachnum;
cout<<"奖励"<<endl;
cin>>award;
/*需要按循序排列*/
Teacher ls;
ls.setid(id);
ls.setname(name);
ls.setgrade(grade);
ls.calstation();
ls.setleave(leave);
ls.setteachnum(teachnum);
ls.calteachsalary();
ls.setaward(award);
ls.calorigsalary();
ls.caltax();
ls.calrealssalary();
ls.calprintbill();
}
还有就是计算那个人所得税那里怎么变成了负数,我实在找不到问题所在,也希望高手们帮帮忙了,谢谢!!!