fork(1) download
  1. #include<iostream>
  2. #include <vector>
  3.  
  4. struct employee
  5. {
  6. char name[20];
  7. float salary;
  8. int birthday;
  9. char sex [10];
  10. };
  11.  
  12. int main()
  13. {
  14. employee emp[100];
  15.  
  16. {
  17. int n, i;
  18.  
  19. std::cout << "A program for collecting employee information";
  20. std::cout << std::endl;
  21. std::cout << "And displaying the collected information";
  22. std::cout << std::endl << std::endl;
  23. std::cout << "How many employees:";
  24. std::cin >> n;
  25. std::cout << std::endl;
  26.  
  27. std::cout << "Enter the following information:"<<std::endl;
  28. std::cout << std::endl;
  29.  
  30. for(int i=0; i<n; i++)
  31. {
  32. std::cout << "Enter information for employee no: " << i;
  33. std::cout << std::endl;
  34.  
  35. std::cout<<"Enter the Employee name :" ;std::cin>>emp[i].name;
  36. std::cout<<"Enter the salary :";std::cin>>emp[i].salary;
  37. std::cout<<"Enter the birthday :";std::cin>>emp[i].birthday ;
  38. std::cout<<"Enter the sex :";std::cin>>emp[i].sex;
  39. std::cout<<std::endl;
  40. }
  41.  
  42. {
  43. employee temp;
  44. for(int i = 0; i < n; i++)
  45. {
  46. for(int j = i+1; j < n; j++)
  47. {
  48. if(emp[i].salary<emp[j].salary)
  49. {
  50. temp=emp[i];
  51. emp[i]=emp[j];
  52. emp[j]=temp;
  53. }
  54. }
  55. }
  56.  
  57. std::cout << "Employee entered information:"<< std::endl;
  58. std::cout << "============================" << std::endl;
  59. std::cout << "Name salary birthday Sex " << std::endl;
  60.  
  61. for(i = 0; i < n; i++)
  62. {
  63. std::cout << emp[i].name << "\t";
  64. std::cout << emp[i].salary << "\t";
  65. std::cout << emp[i].birthday; std::cout << "\t";
  66. std::cout << emp[i].sex ;
  67. std::cout << std::endl;
  68.  
  69. }
  70.  
  71. int highest_salary=0;
  72. int total_salary=0;
  73. for(i = 0; i < n; i++)
  74. {
  75. if(emp[i].salary > highest_salary)
  76. {
  77. highest_salary = emp[i].salary;
  78. }
  79. total_salary += emp[i].salary;
  80. }
  81. std::cout<<std::endl;
  82. std::cout << "Total Salary: " << total_salary <<std::endl;
  83. std::cout << "============"<<std::endl;
  84. std::cout << "Highest Salary: " << highest_salary << std::endl;
  85. std::cout << "=============="<<std::endl;
  86.  
  87. float tax=0;
  88. float salary=0;
  89.  
  90. if(emp[i].salary <= 1999)
  91. {
  92. tax = (emp[i].salary*5)/100.0;
  93. }
  94. else if (emp[i].salary<=2999)
  95. {
  96. tax=(emp[i].salary*7.5)/100.0;
  97. }
  98.  
  99. else if (emp[i].salary<=3999)
  100. {
  101. tax=(emp[i].salary*10)/100.0;
  102. }
  103. else if (emp[i].salary>4000)
  104. {
  105. tax=(emp[i].salary*15)/100.0;
  106. }
  107.  
  108. salary=emp[i].salary-tax;
  109.  
  110. std::cout<<"Salary after tax :"<<" Employee Name : "<<std::endl;
  111. std::cout<<"================ " <<" ============="<<std::endl;
  112. for(i = 0; i < n; i++)
  113. std::cout << salary <<" " << emp[i].name << std::endl;
  114. }
  115. }
  116. }
Success #stdin #stdout 0s 3036KB
stdin
5
asas 5000 1988 m
adre 10000 1965 m
jhiu 8000 198 f
iuyrt 11000 1965 m
poiu 6000 1945 f
stdout
A program for collecting employee information
And displaying the collected information

How many employees:
Enter the following information:

Enter information for employee no: 0
Enter the Employee name :Enter the salary :Enter the birthday :Enter the sex :
Enter information for employee no: 1
Enter the Employee name :Enter the salary :Enter the birthday :Enter the sex :
Enter information for employee no: 2
Enter the Employee name :Enter the salary :Enter the birthday :Enter the sex :
Enter information for employee no: 3
Enter the Employee name :Enter the salary :Enter the birthday :Enter the sex :
Enter information for employee no: 4
Enter the Employee name :Enter the salary :Enter the birthday :Enter the sex :
Employee entered information:
============================
Name  salary birthday   Sex	
iuyrt	11000	1965	m
adre	10000	1965	m
jhiu	8000	198	f
poiu	6000	1945	f
asas	5000	1988	m

Total Salary: 40000
============
Highest Salary: 11000
==============
Salary after tax :  Employee Name :   
================    =============
0                   iuyrt
0                   adre
0                   jhiu
0                   poiu
0                   asas