Sunday 16 August 2015

WAP in java to accept an age of an employee and calculate Bonus based on following:If age >25 then bonus is 5000,otherwise 3000.

//Bonus program using conditional operator

import java.util.Scanner;

class Bonus {

public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter an age:");
int age=sc.nextInt();
int b;

b=(age>25)?5000:3000;
System.out.println("Your Bonus:"+b);
}

}

No comments:

Post a Comment