fork download
  1. #include <cstdio>
  2. #include <string>
  3. using namespace std;
  4. class Worker
  5. {
  6. string Account;
  7. void NewAccnt(string newAccount)
  8. {
  9. this->Account = newAccount;
  10. }
  11. };
  12. class FullTimeWorker : public Worker
  13. {
  14. float Salary;
  15. public:
  16. void NewSalary(float newSalary)
  17. {
  18. this->Salary = newSalary;
  19. }
  20. float Payment()
  21. {
  22. return Salary;
  23. }
  24. };
  25. class HourlyEmployee : public Worker
  26. {
  27. public:
  28. float HourlyRate;
  29. float Hours;
  30. public:
  31. void NewHRate(float newHourlyRate)
  32. {
  33. this->HourlyRate = newHourlyRate;
  34. }
  35. void NewHours(float newHours)
  36. {
  37. Hours = newHours;
  38. }
  39. float Payment()
  40. {
  41. return HourlyRate * Hours;
  42. }
  43. };
  44. int main() {
  45. HourlyEmployee w1;
  46. w1.NewHRate(45.50);
  47. w1.NewHours(10);
  48. float payment = 164*w1.HourlyRate;
  49. printf("Monthly salary: %.2f", payment);
  50. }
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
Monthly salary: 7462.00