Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. using namespace std;
  5. struct Employee
  6. {
  7. string surname;
  8. int day;
  9. double tariff;
  10. };
  11. int main()
  12. {
  13. Employee employees[5];
  14. ifstream f;
  15. int k = 0, ch, n, summa = 0;
  16. string outputPath;
  17.  
  18. f.open("1.txt");
  19. while (!f.eof())
  20. {
  21. f >> employees[k].surname >> employees[k].day >> employees[k].tariff;
  22. cout << employees[k].surname << " " << employees[k].day << " " << employees[k].tariff << endl;
  23. k++;
  24. }
  25. f.close();
  26. bool b = true;
  27. double sumOfSalaries=0;
  28.  
  29. while (b == true)
  30. {
  31. cout << "1 - change, 2 - save, 3 - summa, 4 - end" << endl;
  32. cin >> ch;
  33. switch (ch)
  34. {
  35. case 1:
  36. cout << "nomer stroki 0-" << k - 1 << endl;
  37. cin >> n;
  38. cout << "Vvedite novie znacneiya" << endl;
  39. cout << "surname" << endl;
  40. cin >> employees[n].surname;
  41. cout << "day" << endl;
  42. cin >> employees[n].day;
  43. cout << "tariff" << endl;
  44. cin >> employees[n].tariff;
  45. break;
  46. case 3:
  47. sumOfSalaries=0;
  48. for(int i =0 ; i<k; i++)
  49. {
  50. sumOfSalaries+=employees[i].tariff * employees[i].day;
  51. }
  52. cout << "total salary of all employees = " << sumOfSalaries << endl;
  53. break;
  54. case 4:
  55. b = false;
  56. break;
  57. case 2:
  58. cout << "vvedite pyt sohraneniya" << endl;
  59. cin >> outputPath;
  60. ofstream fo;
  61. fo.open(outputPath.c_str());
  62. for (int i = 0; i < k; i++)
  63. {
  64. fo << employees[i].surname << " " << employees[i].day << " " << employees[i].tariff << endl;
  65. }
  66. fo.close();
  67. break;
  68.  
  69.  
  70. }
  71. }
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement