A superclass Worker has been defined to store the details of a worker. Define a subclass Wages to compute the monthly wages for the worker. The details/specifications of both the classes are given below:
Class name: Worker
Data Members/instance variables:
Name:
to store the name of the worker
Basic: to store the basic pay in decimals Member functions:
Worker (…): Parameterised constructor to assign values to the instance variables
void display (): display the worker’s details
Class name: Wages
Data Members/instance variables:
hrs: stores the hours worked rate:
stores rate per hour wage: stores the overall wage of the worker Member functions:
Wages (…): Parameterised constructor to assign values to the instance variables of both the classes
double overtime (): Calculates and returns the overtime amount as (hours*rate)
void display (): Calculates the wage using the formula wage = overtime amount +
Basic pay and displays it along with the other details
Specify the class Worker giving details of the constructor () and void display ( ).
Using the concept of inheritance,
specify the class Wages giving details of constructor ( ), double-overtime () and void display (). The main () function need not be written.