fork 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;
  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. void bubb(employee emp,int n); //bubble sort
  43.  
  44. {
  45. employee temp;
  46. for(int j = 0;j < n; j++)
  47. {
  48. if(emp[j].salary<emp[j+1].salary)
  49. {
  50. for(int i = j; i < n-1; i++)
  51. {
  52. temp=emp[i];
  53. emp[i]=emp[i+1];
  54. emp[i+1]=temp;
  55. }
  56. }
  57. }
  58.  
  59. std::cout << "Employee entered information:"<< std::endl;
  60. std::cout << "============================" << std::endl;
  61. std::cout << "Name salary birthday Sex " << std::endl;
  62.  
  63. for(i = 0; i < n; i++)
  64. {
  65. std::cout << emp[i].name << "\t";
  66. std::cout << emp[i].salary << "\t";
  67. std::cout << emp[i].birthday; std::cout << "\t";
  68. std::cout << emp[i].sex ;
  69. std::cout << std::endl;
  70.  
  71. }
  72.  
  73. int highest_salary=0;
  74. int total_salary=0;
  75. for(i = 0; i < n; i++)
  76. {
  77. if(emp[i].salary > highest_salary)
  78. {
  79. highest_salary = emp[i].salary;
  80. }
  81. total_salary += emp[i].salary;
  82. }
  83. std::cout<<std::endl;
  84. std::cout << "Total Salary: " << total_salary <<std::endl;
  85. std::cout << "============"<<std::endl;
  86. std::cout << "Highest Salary: " << highest_salary << std::endl;
  87. std::cout << "=============="<<std::endl;
  88.  
  89. //void main(); //calc tax
  90.  
  91. float tax=0;
  92. float salary=0;
  93.  
  94. if(emp[i].salary <= 1999)
  95. {
  96. tax = (emp[i].salary*5)/100;
  97. }
  98. else if (emp[i].salary<=2999)
  99. {
  100. tax=(emp[i].salary*7.5)/100;
  101. }
  102.  
  103. else if (emp[i].salary<=3999)
  104. {
  105. tax=(emp[i].salary*10)/100;
  106. }
  107. else if (emp[i].salary>4000)
  108. {
  109. tax=(emp[i].salary*15)/100;
  110. }
  111.  
  112. salary=emp[i].salary-tax;
  113.  
  114. std::cout<<"Salary after tax :"<<" Employee Name : "<<std::endl;
  115. std::cout<<"================ " <<" ============="<<std::endl;
  116. for(i = 0; i < n; i++)
  117. std::cout << salary <<" " << emp[i].name << std::endl;
  118. }
  119. }
  120. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:63:17: error: ‘i’ was not declared in this scope
prog.cpp:75:17: error: ‘i’ was not declared in this scope
prog.cpp:94:20: error: ‘i’ was not declared in this scope
prog.cpp:112:24: error: ‘i’ was not declared in this scope
stdout
Standard output is empty