Question
Define a class Employee with following members: (20 points) Data Members: Data Type Name Modifier Description Private Employee number Private Employee Name Private Number of
Data Members: Data Type Name Modifier Description Private Employee number Private Employee Name Private Number of hours worked for each day Array double [7 Hours 7] Private Salary for each day Private Per hour salary Private Gross Salary Integer Eno String Ename Array doublel7 Salary[7] double Rate double Gross Salary
Methods Modifier Name Description Employee Constructor to assign values to blanks or 0 Public Inpu Method to take the input of Eno, Ename, Hours [7], Rate and call Calculate) Public Display To display the contents of all fields Public Calculate) Calculates the salary for each day as per the table below, and then calculates Gross Salary
The Salary for each day is calculated as per the following criteria:
First 8 hours are paid as per the hourly rate.
Next 4 hours are pald at the rate of 1.5 rate
Remaining hours are paid at the rate of 2 rate
Weekends are paid at the rate of 2'rate
The Input method should verify that the number of hours have a valid input for each day (0 and-24). Use appropriate code for the same.
The program should create an object of Employee and call the methods for doing the operations. The field values should be displayed in the end.
(2 points each)
2. What is a well-encapsulated class definition?
3. When should an instance variable in a class definition be private, and when shouldit be public?
4. Under what circumstances would you define a private method?
5. In a class definition, is anything private ever part of the class interface?
6. In a class definition, is the body of any method definition ever part of the class interface?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started