#include<iostream.h>
#include <vector>
#include <stdio.h> //ahmed.h
#include<conio.h>
struct employee
{
char name[20];
float salary;
int birthday;
char sex [10];
};
void main()
{
employee emp[100];
{
int n;
cout << "A program for collecting employee information";
cout << endl;
cout << "And displaying the collected information";
cout << endl << endl;
cout << "How many employees:";
cin >> n;
cout << endl;
cout << "Enter the following information:"<<endl;
cout << endl;
for (int i=0; i<n; i++){
cout << "Enter information for employee no: " << i;
cout << endl;
cout<<"Enter the Employee name :" ;cin>>emp[i].name;
cout<<"Enter the salary :";cin>>emp[i].salary;
cout<<"Enter the birthday :";cin>>emp[i].birthday ;
cout<<"Enter the sex :";cin>>emp[i].sex;
cout<<endl;
}
void bubb(employee emp,int n); //bubble sort
{
employee temp;
for(int j=0;j<n;j++)
{
if(emp[j].salary<emp[j+1].salary)
{
for(int i=j;i<n-1;i++)
{
temp=emp[i];
emp[i]=emp[i+1];
emp[i+1]=temp;
}
}
}
cout << "Employee entered information:"<< endl;
cout << "============================" << endl;
cout << "Name salary birthday Sex " << endl;
for( i=0;i<n;i++)
{
cout << emp[i].name << "\t";
cout << emp[i].salary << "\t";
cout << emp[i].birthday; cout << "\t";
cout << emp[i].sex ;
cout << endl;
}
int highest_salary=0;
int total_salary=0;
for ( i = 0; i < n; i++) {
if (emp[i].salary > highest_salary)
highest_salary = emp[i].salary;
total_salary += emp[i].salary;
}
cout<<endl;
cout << "Total Salary: " << total_salary <<endl;
cout << "============"<<endl;
cout << "Highest Salary: " << highest_salary << endl;
cout << "=============="<<endl;
void main(); //calc tax
float tax=0;
float salary=0;
if (emp[i].salary<=1999)
{
tax=(emp[i].salary*5)/100;
}
else if (emp[i].salary<=2999)
{
tax=(emp[i].salary*7.5)/100;
}
else if (emp[i].salary<=3999)
{
tax=(emp[i].salary*10)/100;
}
else if (emp[i].salary>4000)
{
tax=(emp[i].salary*15)/100;
}
salary=emp[i].salary-tax;
cout<<"Salary after tax :"<<" Employee Name : "<<endl;
cout<<"================ " <<" ============="<<endl;
for( i=0;i<n;i++)
cout<< salary<<" " << emp[i].name<<endl;
}
}
}