Join Sarthaks eConnect Today - Largest Online Education Community!
0 votes
asked in Computer by (71.8k points)

Write a class with name employee and basic as its data members, to find the gross pay of an employee of the following allowances and deductions 

DA = 25% of basic pay

HRA = 15% of basic pay

PF = 8.33% of basic pay

Net Pay = Basic pay + DA + HRA

Gross Pay = Net Pay – PF

1 Answer

+1 vote
answered by (68k points)
selected by
Best answer

import jave.i0.*; 

public class employee


public static void main (string args [ ]) throws IO Exception


int basic; double bra da, pf, n pay,gross;

gross = 0

Input Stream Reader read = new Input Stream Reader (;

Buffered Reader in = new Buffered Reader (read); 

System.out.printIn (“Enter basic salary”);

basic = Integer.parseInt ( Line ( ));

da = basic * 25/100

hra = basic * 15/100

pf = basic * 8.33/100;

npay = da + hra + basics; gross = npay – pf; 

System.out.printIn (“The net pay =” + npay); 

System.out.printIn (“The gross pay =” + gross);



Related questions

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.

One Thought Forever

“There is a close connection between getting up in the world and getting up in the morning.“
– Anon