🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
In any professional environment, understanding the components that make up an employee's salary is crucial. The gross salary is the sum total of the basic salary along with any additional allowances before any deductions. In this guide, we will explore how to compute the gross salary of an employee using a simple Java program.
Components of Salary
For our program, the gross salary will consist of:
Basic Salary: The foundational pay.
HRA (House Rent Allowance): Typically a percentage of the basic salary.
DA (Dearness Allowance): Another percentage of the basic salary.
Java Program to Calculate Gross Salary of Employee
import java.util.Scanner;
public class GrossSalaryCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter Basic Salary of the Employee:");
double basic = scanner.nextDouble();
double hra = 0.10 * basic; // 10% of basic
double da = 0.08 * basic; // 8% of basic
double grossSalary = basic + hra + da;
System.out.println("Employee Gross Salary Breakdown:");
System.out.println("Basic: " + basic);
System.out.println("HRA: " + hra);
System.out.println("DA: " + da);
System.out.println("Gross Salary: " + grossSalary);
}
}Output:
Enter Basic Salary of the Employee:
10000
Employee Gross Salary Breakdown:
Basic: 10000.0
HRA: 1000.0
DA: 800.0
Gross Salary: 11800.0Step by Step Explanation:
Scanner scanner = new Scanner(System.in);
System.out.println("Enter Basic Salary of the Employee:");
double basic = scanner.nextDouble(); double hra = 0.10 * basic; // 10% of basic
double da = 0.08 * basic; // 8% of basic double grossSalary = basic + hra + da; System.out.println("Employee Gross Salary Breakdown:");
System.out.println("Basic: " + basic);
System.out.println("HRA: " + hra);
System.out.println("DA: " + da);
System.out.println("Gross Salary: " + grossSalary);Conclusion
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment