Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- struct Employee
- {
- string surname;
- int day;
- double tariff;
- };
- int main()
- {
- Employee employees[5];
- ifstream f;
- int k = 0, ch, n, summa = 0;
- string outputPath;
- f.open("1.txt");
- while (!f.eof())
- {
- f >> employees[k].surname >> employees[k].day >> employees[k].tariff;
- cout << employees[k].surname << " " << employees[k].day << " " << employees[k].tariff << endl;
- k++;
- }
- f.close();
- bool b = true;
- double sumOfSalaries=0;
- while (b == true)
- {
- cout << "1 - change, 2 - save, 3 - summa, 4 - end" << endl;
- cin >> ch;
- switch (ch)
- {
- case 1:
- cout << "nomer stroki 0-" << k - 1 << endl;
- cin >> n;
- cout << "Vvedite novie znacneiya" << endl;
- cout << "surname" << endl;
- cin >> employees[n].surname;
- cout << "day" << endl;
- cin >> employees[n].day;
- cout << "tariff" << endl;
- cin >> employees[n].tariff;
- break;
- case 3:
- sumOfSalaries=0;
- for(int i =0 ; i<k; i++)
- {
- sumOfSalaries+=employees[i].tariff * employees[i].day;
- }
- cout << "total salary of all employees = " << sumOfSalaries << endl;
- break;
- case 4:
- b = false;
- break;
- case 2:
- cout << "vvedite pyt sohraneniya" << endl;
- cin >> outputPath;
- ofstream fo;
- fo.open(outputPath.c_str());
- for (int i = 0; i < k; i++)
- {
- fo << employees[i].surname << " " << employees[i].day << " " << employees[i].tariff << endl;
- }
- fo.close();
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement