Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
9.8k views
in Computer by (49.9k points)
closed by

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.

1 Answer

+1 vote
by (49.0k points)
selected by
 
Best answer

importjava.io.*; 

class worker

{ String Name; double Basic; 

public worker (String n, double b) 

{ Name = n; Basic = b; 

public void display ( ) 

System.out.println (Name); 

System.out.println (Basic); 

class wages extends worker 

int hrs, rate; 

double wage public wage (string n, double b, int h, int r, double w) 

super (n, b); 

hrs = h; 

rate = r; 

wage = w; 

public double overtime () 

return (hours*rate); 

public void display ( ) 

{ super.display (); 

wage = overtime () + Basic; 

System.out.prinln(wages); 

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...