Categories
Uncategorised

Structures – Employee Data

/* Copyright (C) 2007 Ankur Banerjee. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. http://www.fsf.org/licensing/licenses/lgpl.html /

/ Program to manipulate employee data /

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>

struct perks
{
float da, hra, total;
int bonus;
};

struct date
{
int dd, mm, yy;
};

struct emp
{
int num, basic;
char name[50], des[30];
date dob;
perks perk;
float net;
} e[5];

void main()
{
clrscr();
for (int i=0; i<5; i++)
{
cout<<“Enter data for employee number”<<i+1<<endl
<<“Enter employee number : “;
cin>>e[i].num;
cout<<“Enter employee name :”;
gets(e[i].name);
cout<<“Enter employee date of birth in DD MM YYYY format :”;
cin>>e[i].dob.dd>>e[i].dob.mm>>e[i].dob.yy;
cout<<“Enter basic salary of employee :”;
cin>>e[i].basic;
e[i].perk.bonus = 800;
e[i].perk.da = 0.15 * e[i].basic;
e[i].perk.hra = 0.12 * e[i].basic;
e[i].perk.total = e[i].perk.bonus + e[i].perk.da + e[i].perk.hra;
e[i].net = e[i].basic + e[i].perk.total;
if (e[i].net>25000)
strcpy (e[i].des, “Manager”);
else if ((e[i].net>15000) &&(e[i].net<=25000))
strcpy (e[i].des, “Executive”);
else if (e[i].net<=15000)
strcpy (e[i].des, “Non Executive”);
}
for (int j=0; j<5; j++)
{
cout<<endl<<“Data for employee “<<j+1<<endl;
cout<<“Employee number :”<<e[j].num<<endl
<<“Employee name :”;
puts(e[j].name);
cout<<“Employee designation :”<<
puts(e[j].des);
cout<<“Employee date of birth:”<<e[j].dob.dd<<” “<<e[j].dob.mm<<“”<<e[j].dob.yy<<endl;
cout<<“Employee basic salary :”<<e[j].basic<<endl
<<“DA :”<<e[j].perk.da<<endl
<<“HRA :”<<e[j].perk.hra
<<endl<<“Bonus :”<<e[j].perk.bonus
<<endl<<“Total perks :”<<e[j].perk.total<<endl
<<“Net salary :”<<e[j].net<<endl;
}
getch();
}

/ Output */

Enter data for employee number 1
Enter employee number :42
Enter employee name : Arthur Dent
Enter employee date of birth in DD MM YYYY format :20
7
1990
Enter basic salary of employee :4500

Data for employee 1
Employee number :42
Employee name : Arthur Dent
Employee designation : Non Executive
Employee date of birth : 20 7 1990
Employee basic salary :4500
DA :675
HRA :540
Bonus :800
Total perks :2015
Net salary :6515

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.