#include
#include
using namespace std;
The class Employ
{
Public:
Employ ()
{name="NULL". }
Employ (string na)
{name=na; }
Void the set ()
{
cout<" Please enter the name: "& lt;
}
Void the display ()
{cout<" Name: "& lt;
String name;
};
The class Manager: virtual public Employ
{
Public:
Manager (string na, float s) : Employ (na)
{s=salary1; }
Manager ()
{
Name="NULL".
Salary1=0;
}
Void the set ()
{
cout<" Please enter the managers name: "& lt;
cout<" Please enter a fixed salary: managers "& lt;
}
Void the display ()
{
cout<" Type: the Manager "& lt;
Protected:
Float salary1;
};
The class Hourly_Worker: virtual public Employ
{
Public: Hourly_Worker (string na, float wh, float p) : Employ (na)
{
Workhour=wh;
Pay=p;
}
Hourly_Worker ()
{
Name="NULL".
Workhour=0;
Pay=0;
}
Void the set ()
{
cout<" Please enter the hourly workers name: "& lt;
cout<" Please enter the hourly workers work hours: "& lt;
cout<" Please enter the timing of the workers' pay: "& lt;
}
Float salary2 ()
{
Float salary2;
Salary2=workhour * pay;
Return salary2;
}
Void the display ()
{
cout<" Type: Hourly worker "& lt;
Protected:
Float workhour;
Float pay;
};
The class Piece_Worker: virtual public Employ
{
Public:
Piece_Worker (string na, int wp, float p) : Employ (na)
{
Workpiece=wp;
Pay=p;
}
Piece_Worker ()
{
Name="NULL".
Workpiece=0;
Pay=0;
}
Float salary3 ()
{
Float salary3;
Salary3=workpiece * pay;
Return salary3;
}
Void the set ()
{
cout<" Please enter the name piece workers: "& lt;
cout<" Please enter part-time workers production quantity of work: "& lt;
cout<" Please enter the part-time workers work unit price: "& lt;
}
Void the display ()
{
cout<" Type: piece worker "& lt;
Protected:
Int workpiece;
Float pay;
};
The class Commission_Worker: virtual public Manager
{
Public: Commission_Worker (string na, float s, int, wp, bp, int, float p) : the Manager (na, s)
{
Workpiece=wp;
Basicpiece=bp;
Pay=p;
}
Commission_Worker ()
{
Name="NULL".
Salary1=0;
Workpiece=0;
Basicpiece=0;
Pay=0;
}
Float salary4 ()
{
Float salary4;
If (workpiece<=basicpiece)
Salary4=salary1;
The else salary4=salary1 + (workpiece - basicpiece) * pay;
Return salary4;
}
Void the set ()
{
cout<" Please enter the contract name: "& lt;
cout<" Please enter a contract base salary: "& lt;
cout<" Please enter the contract quantity of the actual work: "& lt;
cout<" Please enter the contractors minimum quantity of work: "& lt;
cout<" Please enter the contract more than the minimum work after the workpiece unit price: "& lt;
}
Void the display ()
{
cout<" Type: appointed the worker "& lt;
Protected:
Int workpiece;
Int basicpiece;
Float pay;
};
Int main ()
{
int i;
Manager m1;
Hourly_Worker h1.
Piece_Worker p1.
Commission_Worker c1;
cin> i;
The switch (I)
{
Case 1:
M1. Set ();
M1. The display ();
Case 2:
H1. The set ();
H1. The display ();
Case 3:
P1. The set ();
P1. The display ();
Case 4:
C1. Set ();
C1. The display ();
}
return 0;
}
Could you tell me how to implement the program input employee information by means of documents, and wage, and different employee's salary is input to a file,
CodePudding user response:
Use this file API implementation such as:# include & lt; stdio.h>
# define the SIZE 2
Struct student_type
{
Char name [10].
Int num.
int age;
Char addr [10].
} stud [SIZE];
Void the save ()
{
FILE *fp;
int i;
If ((fp=fopen (" stu_list ", "wb"))==NULL)
{
Printf (" cant open the file ");
exit(0);
}
for(i=0; i
If (fwrite (& amp; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull