Computer Science, asked by ketan5947, 9 months ago

write a java coding on the following details: a) class name - name , pay
b) data members- double salary, da, hra , gross salary
c) member method
1 ) void input data () - to input the salary further
2) void calculate - to calculate da which is 12% of the salary, gross salary=da +hra+ salary
3) void print result ()- to print the salary and the gross salary.​

Answers

Answered by mafattah
3

Answer:

public class Pay

{

public double salary;

public double da;

public double hra;

public double gross_salary;

// constructor

public Pay(double salary) {

this.salary = salary;

}

public void input_data(double salary)

{

this.salary = salary;

this.da = (salary * 12) /100;

this.hra = (salary * 25) / 100;

this.gross_salary = this.salary + this.da + this.hra;

}

public void calculate_da(double salary)

{

this.salary = salary;

this.da = (salary * 12) /100;

}

public void print_result()

{

System.out.printf(" Salary is: %f", this.salary);

System.out.printf(" Gross Salary is: %f", this.gross_salary);

}

}

Similar questions