Categories
Uncategorised

Structures – Customer Bill

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

/ Structures – Program to manipulate bills /

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

struct cust
{
int num, units;
char name[50];
float net;
} c[5];

void main()
{
clrscr();
for (int i=0; i<5; i++)
{
cout<<endl<<“Enter data for customer “<<i+1<<endl
<<“Enter customer number : “;
cin>>c[i].num;
cout<<“Enter customer name : “;
gets(c[i].name);
cout<<“Enter the number of units consumed : “;
cin>>c[i].units;
if (c[i].units <= 100)
c[i].net = 0.4 * c[i].units;
else if ((c[i].units > 100) && (c[i].units <= 200))
c[i].net = (c[i].units – 100) * 0.5 + 40;
else if ((c[i].units > 200) && (c[i].units <= 300))
c[i].net = (c[i].units – 200) * 0.75 + 90;
else if (c[i].units > 300)
c[i].net = (c[i].units – 300) + 165;
}
for (int j=0; j<5; j++)
{
cout<<endl<<“Data for customer “<<j+1<<endl
<<“Customer number : “<<c[j].num<<endl
<<“Customer name : “<<
puts(c[j].name);

cout<<“Number of units consumed : “<<c[j].units<<endl
<<“Total bill : “<<c[j].net<<endl;
}
getch();
}

/ Output */

Enter data for customer 4
Enter customer number : 53
Enter customer name : Arthur Dent
Enter the number of units consumed : 256

Data for customer 1
Customer number : 53
Customer name : Arthur Dent
Number of units consumed : 256
Total bill : 132

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