Java Programming | Gross salary


This is a tutorial for calculating gross salary in java. The program is given below that takes basic salary from user and calculates gross salary and prints it. The program is not extendable. Go enjoy the program. Lets begin…….

Program for gross salary in java.

//import Scanner as we require it.
import java.util.Scanner;

// the name of our class its public
public class GrossSalary {
	//void main
		public static void main (String[] args)
			//declare float
			float sal,gsal;
			//print message
			System.out.println("Enter Basic salary:");
			//Take input
			Scanner input = new Scanner(;
			 sal = input.nextFloat();
		     gsal = sal+(sal*0.4f)+(sal*0.2f);
			//print the gsal
			System.out.println("Gross salary = "+gsal);


Enter Basic salary:
Gross salary = 3200.0

How it works

  1. The program prints the message to enter basic salary.
  2. The user enters basic salary.
  3. Gross salary is calculated
  4. The gross salary is printed.

Extending it

The program cannot be extended. There are no direction in which you can extend. So you cannot extend the program.


  1. Import the Scanner.
  2. Declare the class as public
  3. Add the void main function
  4. Add system.out.println() function with the message to enter basic salary.
  5. Declare input as Scanner.
  6. Take the basic salary and save it in variable.
  7. Calculate Gross salary and save it in other variable.
  8. Add system.out.println() function to print the calculated gross salary.

At the end.

You learnt creating the Java program for Gross salary . So now enjoy the program.

Please comment on the post and share it.
And like it if you liked.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s