Page 484 - Computer science 868 Class 12
P. 484
void display () : displays 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
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
Using the concept of inheritance, specify the class Wages giving details of the constructor ( ), double overtime() and void display
(). You need not write base class and main method.
9. A superclass Electric has been defined to store the details of a customer. Define a subclass Bill to compute the monthly electric
charge of the customer as per the chart given below.
Number of units Rate
First 100 units `250 fixed rental charge
Next 200 units `1 per unit
Above 300 units `1.5 per unit
The details of both the classes are given below:
Class name : Electric
Data Members/Instance variables
name : to store the name of the customer
consno : to store the consumer number of the customer
pre_read : to store previous meter reading
pres_read : to store present meter reading
unit : to store units consumed calculated as
unit = pres_read – pre_read
Member Functions
Electric (…) : parameterised constructor to assign values to data members
void show () : to display the details of the customer
Class name : Bill
Data Members/Instance variables
amt : to store the amount to be paid by the customer
Member Functions
Bill (…) : parameterised constructor to assign values to data members of both classes
void calculate() : calculates the monthly electricity charge as per the conditions given above
void show() : displays the details of the customer and amount to be paid
Using the concept of inheritance, specify the class Bill giving details of the constructor(), void calculate() and void show(). You
need not write base class and main method.
10. A base class Money is defined to store an amount defined in rupees and paisa. A derived class AddMoney is defined which stores
another amount defined in rupees and paisa and finds the total amount. The details of the classes are given below.
Class name : Money
Data Members
int rs1 : To store rupees
int ps1 : To store paisa
Member Methods
Angle(int d1, int m1) : Parameterised constructor to initialise data members of base class
void show() : Displays first amount.
Class name : AddMoney
Data Members
int rs2 : To store rupees
int ps2 : To store paisa
482482 Touchpad Computer Science-XII

