| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2108 人关注过本帖
标题:怎么才能把输出改成像表格那样?
只看楼主 加入收藏
无情云
Rank: 1
等 级:新手上路
帖 子:22
专家分:7
注 册:2010-9-25
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
怎么才能把输出改成像表格那样?
希望高手们帮帮我这个新手,在此先谢谢大家!!!!!
#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();
}

还有就是计算那个人所得税那里怎么变成了负数,我实在找不到问题所在,也希望高手们帮帮忙了,谢谢!!!
搜索更多相关主题的帖子: 输出 表格 
2010-10-16 21:07
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
收藏
得分:10 
应该学会调试程序!

★★★★★为人民服务★★★★★
2010-10-16 21:18
无情云
Rank: 1
等 级:新手上路
帖 子:22
专家分:7
注 册:2010-9-25
收藏
得分:0 
回复 2楼 cnfarer
刚刚学习啊,还是新手呢。
2010-10-16 21:24
zfk305
Rank: 2
等 级:论坛游民
帖 子:12
专家分:24
注 册:2010-6-8
收藏
得分:10 
期待高手加入!!
2010-10-19 11:36
快速回复:怎么才能把输出改成像表格那样?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052516 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved