Consider the program: Enter Basic Salary ($): 12000 Enter HRA ($): 150 Enter TA ($): 120 Enter others ($): 450 Net Salary is: $ 10680.00 C FAQ (s) C Advance programs C/C Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More. Was this page helpful? Please share with your friends. May 11, 2017 Problem:- Java program for salary of an employee or java program for find the salary of an employee with employee grade or simple employee program in java or employee details program in java or employee salary calculation program in java or employee details program in java using inheritance or java program for employee details using array or java program for employee payroll or employee.
I have a problem which i'm trying to solve.
In a company an emplopyee is paid as under:If his basic salary is less than Rs. 1500, then HRA = 10% of base salary and DA = 90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the Employee's salary is input, write a program to find his gross salary.
Input
3
1203
10042
1312
Expected Output
2406
20383.2
2624
Actual Output
1.5668931843000004E8
19579.800000000003
2.0325629952E8
Java Code...
I can't understand where I'm going wrong. The compiler is not showing any error.
EDIT 1:
I changed the line 'tsal = n * hra * da' to 'tsal = n + hra + da' in the first if statement and changed the system.output line to
still i'm not getting the desired output. Any idea how to get double value rounded off to 1 decimal place??
Lucy
LucyLucy
1 Answer
Change this line:
tsal = n * hra * da;
to tsal = n + hra + da;
That will help for < 1500
![Program To Find Gross Salary In Java Program To Find Gross Salary In Java](http://2.bp.blogspot.com/-nCr8C-x190s/UzVojtecjbI/AAAAAAAABLY/54zOftvN1Wk/s1600/Screenshot+2014-03-28+17.00.01.png)
Also, for your RS > 1500, if DA = 98% then your code
da = 0.9 * n;
should be da = 0.98 * n;
JFPicardJFPicard
Not the answer you're looking for? Browse other questions tagged javatype-conversion or ask your own question.
I have again a problem regarding on how to display the calculated wage of the employee..When I type in the hourly rate, the Gross Salary won't display..
Here's what I've done so far..
The WageCalcu.java
The Employee.java
drayldrayl
4 Answers
I'm sure you meant:
System.out.printf( 'nGross Salary: %f', pay);
One more thing
Should be
If you're really expecting a real number.
nullpotentnullpotent
I would put:
System.out.printf( 'nGross Salary: %.2f', pay);
to show 2 decimals. Eugene MoshkolaEugene Moshkola
You have missed %s in
printf( 'nGross Salary: ', + pay );
![Salary Salary](/uploads/1/2/5/5/125598823/469218210.png)
RaksRaks
Five years late to this party, but I'll speak my piece.
You've set it up to determine how many overtime hours an employee has, but you're not calculating their overtime pay.
What you have:
What it should be:
Jake DoeJake Doe