Functions in Java
Functions in Java
Methods:
void input( ) – to accept the employee details
void print( ) - to print the Employee ID, basic and total salary
void salaryCal( ) – to calculate the total salary of the employee that is calculated
as follows:
HRA = 30% of basic pay
DA = 40% of basic pay
total _salary = basic pay + HRA + DA
If employee code <= 15, a special allowance of 20% of basic is added to
total_salary else a special allowance of Rs.1000 is added to the total_salary.
Write the main function to create an object of employee class and invoke the
methods appropriately to accomplish the task.
2. Design a class Student to check whether a student is eligible for taking admission
in Class XI with the following specifications:
Instance variables/Data Members:
Id ( integer value ) : stores the id of a student
Physics ( integer value ) : stores marks secured in Physics
Chemistry ( integer value ) : stores marks secured in Chemistry
Maths ( integer value ) : stores marks secured in Maths
streamCode (integer value ) : stores stream code
Member Methods:
void input( ) : to accept the data members by accepting the details of the student
void check ( ) : to check the eligibility for course and assign the appropriate
Stream Code to streamCode with the following conditions
Marks Stream Code Eligibility
90 % or more in all the subjects 100 Science with
Computer
Average marks 90 % or more 200 Bio Science
Average marks 80 % or more and less than 90 300 Science with Hindi
%
****************
1|MAYURI’S COMPUTER ACADEMY