Google PlusFacebookTwitter

Structures – Employee Data

By on Mar 23, 2007 in On A Whim | 0 comments

Share On GoogleShare On FacebookShare On Twitter

/* 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. */

/* 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()
for (int i=0; i<5; i++)
cout<<“Enter data for employee number”<<i+1<<endl
<<“Enter employee number : “;
cout<<“Enter employee name :”;
cout<<“Enter employee date of birth in DD MM YYYY format :”;
cout<<“Enter basic salary of employee :”;
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] = e[i].perk.bonus + e[i].perk.da + e[i].perk.hra;
e[i].net = e[i].basic + e[i];
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 :”;
cout<<“Employee designation :”<<
cout<<“Employee date of birth:”<<e[j].dob.dd<<” “<<e[j]<<“”<<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]<<endl
<<“Net salary :”<<e[j].net<<endl;

/* 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
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

Submit a Comment

Your email address will not be published. Required fields are marked *