求一c++程序

来源:百度知道 编辑:UC知道 时间:2024/05/25 19:11:25
求一C++程序 某教师的课酬算法是:按小时付课酬.教授100/H,副教授80讲师60助教40。编写课酬程序,从键盘输入教师姓名、职称、授课时间、然后计算输出该教师应得的课酬.谢谢..好象是用C++多态性做..请给出具体程序代码

#include <stdio.h>
#include <iostream>
using namespace std;

class Person
{
public:
char name[10];
char zhicheng[10];
int count(int time);
};
//正教授
class FP: public Person
{
public:
int count(int time){return time*100;}
};
//副教授
class SP: public Person
{
public:
int count(int time){return time*80;}
};
//讲师
class JP: public Person
{
public:
int count(int time){return time*60;}
};
//助教
class ZP: public Person
{
public:
int count(int time){return time*40;}
};
void main()
{
char name[10];
char zhicheng[10];
int time;
FP fp;
SP sp;
JP jp;
ZP zp;
while (1)
{
cout<<"请输入名字[0]退出:";
cin>>name;
if (name[0] == '0') break;
cout<<"请输入职称(F(正教),S(副教),J(讲师),Z(