Java Programming | Bonus in salary


This is a program for bonus in salary in java. The program is given below that takes input from user and calculates bonus and prints it. The program is extendable. Go enjoy the program. Lets begin……

Program for bonus in salary in java.

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

// the name of our class its public
public class Bonus {
	//void main
		public static void main (String[] args)
			//declare int and char
			int a,b;
			char c;

			//Declare input as scanner
			Scanner input = new Scanner(;

			//Take inputs
			 System.out.println("Enter Salary");
			 a = input.nextInt();
			 System.out.println("Enter Gender:");
		     String g =;
		     char d[] = g.toCharArray();
		     c = d[0];
		     //if-else statement
		        System.out.println("Bonus Applicable :"+b);
		    		 System.out.println("Bonus Applicable :"+b);
		    		System.out.println("Invalid gender");



Enter Salary
Enter Gender:
Bonus Applicable :6000

How it works

  1. The program prints the message to enter salary and gender.
  2. The user enters values.
  3. The bonus is calculated and printed.

Extending it

The program is extendable. Create the program using your own bonus system OR changing the formula of calculating bonus.


  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 salary and gender.
  5. Declare input as Scanner.
  6. Take the inputs and save it in variables.
  7. Add a if-else statement.
  8. Calculate the bonus and save it in variable.
  9. Add system.out.println() function to print the bonus.

At the end.

You learnt creating the Java program for Bonus in 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