#include<iostream.h>
#include <vector>
#include <stdio.h> //ahmed.ha.hnd
#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;
}
elseif (emp[i].salary<=2999)
{
tax=(emp[i].salary*7.5)/100;
}
elseif (emp[i].salary<=3999)
{
tax=(emp[i].salary*10)/100;
}
elseif (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;
}
}
}
/*out put my prgram:
How many employees:5
Enter the following information:
Enter information for employee no: 0
Enter the Employee name :ahahd
Enter the salary :15000
Enter the birthday :1987
Enter the sex :m
Enter information for employee no: 1
Enter the Employee name :asnb
Enter the salary :12000
Enter the birthday :1956
Enter the sex :m
Enter information for employee no: 2
Enter the Employee name :asmar
Enter the salary :14000
Enter the birthday :1965
Enter the sex :f
Enter information for employee no: 3
Enter the Employee name :sara
Enter the salary :25000
Enter the birthday :1960
Enter the sex :f
Enter information for employee no: 4
Enter the Employee name :nera
Enter the salary :2000
Enter the birthday :1980
Enter the sex :f
Employee entered information:
============================
Name salary birthday Sex //does not arrange Salaries well
ahahd 15000 1987 m
asmar 14000 1965 f
sara 25000 1960 f
asnb 12000 1956 m
nera 2000 1980 f
Total Salary: 68000
============
Highest Salary: 25000
==============
Salary after tax : Employee Name :
================ =============
-1.02005e+008 ahahd
-1.02005e+008 asmar //gives me an error when
//calculating the salary tax
-1.02005e+008 sara
-1.02005e+008 asnb
-1.02005e+008 nera
Press any key to continue*/
thank you
when i use // std::cin >> n;
std::cout << std::endl;
or Using Namespace Std , Was correct all the mistakes, but the problem still
when the bubble sort and calc tax
A program for collecting employee information
And displaying the collected information
How many employees:5
Enter the following information:
Enter information for employee no: 0
Enter the Employee name :asas
Enter the salary :5000
Enter the birthday :1988
Enter the sex :m
Enter information for employee no: 1
Enter the Employee name :adre
Enter the salary :10000
Enter the birthday :1965
Enter the sex :m
Enter information for employee no: 2
Enter the Employee name :jhiu
Enter the salary :8000
Enter the birthday :198
Enter the sex :f
Enter information for employee no: 3
Enter the Employee name :iuyrt
Enter the salary :11000
Enter the birthday :1965
Enter the sex :m
Enter information for employee no: 4
Enter the Employee name :poiu
Enter the salary :6000
Enter the birthday :1945
Enter the sex :f
Employee entered information:
============================
Name salary birthday Sex
adre 10000 1965 m
iuyrt 11000 1965 m
poiu 6000 1945 f //Not well arrange Salaries
jhiu 8000 198 f
asas 5000 1988 m
Total Salary: 40000
============
Highest Salary: 11000
==============
Salary after tax : Employee Name :
================ =============
-1.02005e+008 adre
-1.02005e+008 iuyrt
-1.02005e+008 poiu //Does not give me the
//values of salaries after tax
-1.02005e+008 jhiu
-1.02005e+008 asas
Press any key to continue
And displaying the collected informat
How many employees:1
Enter the following information:
Enter information for employee no: 0
Enter the Employee name :assd
Enter the salary :15000
Enter the birthday :1987
Enter the sex :5
Employee entered information:
============================
Name salary birthday Sex
assd 15000 1987 5
Total Salary: 15000
============
Highest Salary: 15000
==============
Salary after tax : Employee Name :
================ =============
12750 assd
Press any key to continue
A program for collecting employee informat
And displaying the collected information
How many employees:3
Enter the following information:
Enter information for employee no: 0
Enter the Employee name :asdd
Enter the salary :1000
Enter the birthday :198
Enter the sex :m
Enter information for employee no: 1
Enter the Employee name :dsre
Enter the salary :2000
Enter the birthday :1965
Enter the sex :m
Enter information for employee no: 2
Enter the Employee name :hguyt
Enter the salary :3000
Enter the birthday :1659
Enter the sex :m
Employee entered information:
============================
Name salary birthday Sex
hguyt 3000 1659 m
dsre 2000 1965 m
asdd 1000 198 m
Total Salary: 6000
============
Highest Salary: 3000
==============
Salary after tax : Employee Name :
================ =============
2700 hguyt
2700 dsre
2700 asdd
Press any key to continue