Pages

Wednesday, 2 August 2017

Write a program to bonus calculation using structure

Q : Write a C program to store the employee details with the following attribute?



Sr No.
Basic Salary
Sales Percentage
Bonus Amount
1
<=7000
<=10
1500
2
<=7000
>=10
3000
3
>7000 and <=15000
<=10
2000
4
>7000 and <=15000
>=10
4000
5
>15000
<=10
2500
6
>15000
>=10
4500

Solution : 


/* ============================================
          Girfa Student Help
          Program : Salary Calculation
          For more program visit :http://girfahelp.blogspot.in/p/c-language-structure-programming.html
================================================*/
#include<stdio.h>
#include<conio.h>
typedef struct stu
{
     int empid;
     int pf;
     int mediclaim;
     int basicsal;
     int sp;

     int salary;
     int bonus;
}EMP;
void main()
{
     EMP ob;
     clrscr();
     printf("Enter Employee ID>> ");
     scanf("%d",&ob.empid);
     printf("Enter Basic Pay>> ");
     scanf("%d",&ob.basicsal);
     printf("Enter Sale Percentage>> ");
     scanf("%d",&ob.sp);
     printf("Enter PF>> ");
     scanf("%d",&ob.pf);
     printf("Enter Mediclaim>> ");
     scanf("%d",&ob.mediclaim);
     if(ob.empid<0 || ob.basicsal<0 || ob.sp<0 || ob.pf<0 || ob.mediclaim<0)
     {
          printf("Unable to calculate Salary");
     }
     else
     {
          if(ob.basicsal<=7000 && ob.sp<=10)
              ob.bonus=1500;
          else if(ob.basicsal<=7000 && ob.sp>=10)
              ob.bonus=3000;
          else if((ob.basicsal<=7000 && ob.basicsal<=15000) &&  ob.sp<=10)
              ob.bonus=2500;
          else if((ob.basicsal<=7000 && ob.basicsal<=15000) &&  ob.sp>=10)
              ob.bonus=4000;
          else if(ob.basicsal>15000 && ob.sp<=10)
              ob.bonus=2500;
          else if(ob.basicsal>15000 && ob.sp>=10)
              ob.bonus=4500;
          ob.salary=ob.basicsal+ob.bonus;
          ob.salary-=(ob.pf+ob.mediclaim);
     }
     printf("\n\tEmployee id\t%d",ob.empid);
     printf("\n\tEmployee Basic Pay\t%d",ob.basicsal);
     printf("\n\tEmployee Sales Paercentage\t%d",ob.sp);
     printf("\n\tEmployee Bonus\t%d",ob.bonus);
     printf("\n\tEmployee PF\t%d",ob.pf);
     printf("\n\tEmployee Mediclaim\t%d",ob.mediclaim);
     printf("\n\tEmployee Salary\t%d",ob.salary);


}

No comments:

Post a Comment