Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mishina violetta #64

Open
wants to merge 7 commits into
base: Mishina_Violetta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions task8/1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#include <iostream>
#include <string>

using namespace std;

class Students
{
private:
string name;
string last_name;
string patronymic;
int group;
int kurs;
int age;

string vname(string name)
{
if (name == " ")
{
cout << " Name = " << endl;
cin >> name;
}
return name;
}

string vlast_name(string last_name)
{
if (last_name == " ")
{
cout << "Last_name = " << endl;
cin >> last_name;
}
return last_name;
}

string vpatronymic(string patronymic)
{
if (patronymic == " ")
{
cout << "Patronymic= " << endl;
cin >> patronymic;

}
return patronymic;
}

int vgroup(int group)
{
if (group == 0)
{
cout << "Group = " << endl;
cin >> group;
}
return group;
}

int vkurs(int kurs)
{
if (kurs == 0)
{
cout << "Kurs = " << endl;
cin >> kurs;
}
return group;
}

int vage(int age)
{
if (age == 0)
{
cout << "Age = " << endl;
cin >> age;
}
return age;
}

public:
Students (string name, string last_name, string patronymic, int group, int kurs, int age)
{
this->name = vname(name);
this->last_name = vlast_name(last_name);
this->patronymic = vpatronymic(patronymic);
this->group = vgroup(group);
this->kurs = vkurs(kurs);
this->age = vage(age);
this->name = name + " " + last_name + " " + patronymic;
}

void show()
{
cout << "Name " << name << endl;
cout << "Last_ame " << last_name << endl;
cout << "Patronymic " << patronymic << endl;
cout << "Group " << group << endl;
cout << "Kurs " << kurs << endl;
cout << "Age " << age << endl;
}
};
int main()
{
Students One(" "," ", " ", 0, 0, 0);
Students Two(" ", " ", " ", 0, 0, 0);
Students Three(" ", " ", " ", 0, 0, 0);
One.show();
Two.show();
Three.show();

return 0;
}


// помогала Екатерина Завидина с условием задачи
165 changes: 165 additions & 0 deletions task8/2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#include <iostream>
#include <string>
#include <fstream> // загрузка библиотеки для работы с файлами

using namespace std;

class Employee
{
private:
string full_name;
string position;
string home_address;
int experience;
string phone_number;
int number_of_hours_worked;
int cost_of_an_hour_of_work;

string vfull_name(string full_name)
{
if (full_name == " ")
{
cout << "Full_name = ";
getline(cin, full_name);
}
return full_name;
}

string vposition(string position)
{
if (position == " ")
{
cout << "Position = ";
cin >> position;
}
return position;
}

string vhome_address(string home_address)
{
if (home_address == " ")
{
cout << "Home_address= ";
getline(cin, home_address);

}
return home_address;
}

int vexperience(int experience)
{
if (experience == 0)
{
cout << "Experience = ";
cin >> experience;
}
return experience;
}

string vphone_number(string phone_number)
{
if (phone_number == "")
{
cout << "Phone_number ";
cin >> phone_number;
}
return phone_number;
}

int vnumber_of_hours_worked(int number_of_hours_worked)
{
if (number_of_hours_worked == 0)
{
cout << "Number_of_hours_worked = ";
cin >> number_of_hours_worked;
}
return number_of_hours_worked;
}

int vcost_of_an_hour_of_work(int cost_of_an_hour_of_work)
{
if (cost_of_an_hour_of_work == 0)
{
cout << "cost_of_an_hour_of_work = " << endl;
cin >> cost_of_an_hour_of_work;
}
return cost_of_an_hour_of_work;
}
public:
Employee() : full_name("Mishina Violetta Aleksandrovna"), position("disigner"), home_address("Ivanovo, Kalina street, building 20, apartment 28"), experience(1), phone_number("+79158175317"), number_of_hours_worked(560), cost_of_an_hour_of_work(400) {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все ясно с Вами - position("disigner") :)

Employee(string full_name, string position, string home_address, int experience, string phone_number, int number_of_hours_worked, int cost_of_an_hour_of_work)
{
this->full_name = vfull_name(full_name);
this->position = vposition(position);
this->home_address = vhome_address(home_address);
this->experience = vexperience(experience);
this->phone_number = vphone_number(phone_number);
this->number_of_hours_worked = vnumber_of_hours_worked(number_of_hours_worked);
this->cost_of_an_hour_of_work = vcost_of_an_hour_of_work(cost_of_an_hour_of_work);
}
void show()
{
string soglasie;
cout << "Full name " << full_name << endl;
cout << "Position " << position << endl;
cout << "Home address " << home_address << endl;
cout << "Experience " << experience << endl;
cout << "Phone number " << phone_number << endl;
cout << "Number of hours worked " << number_of_hours_worked << endl;
cout << "Cost of an hour of work " << cost_of_an_hour_of_work << endl;
cout << "Wages " << wages() << endl;
cout << "Bonus " << bonus() << endl;
cout << "Create file with this information? \nEnter yes/any other key(no): ";
cin >> soglasie;
if (soglasie == "yes")
{
ofstream info;
info.open(full_name + ".txt"); // создаёт или открывает файл
info << "Full name " << full_name << endl;
info << "Position " << position << endl;
info << "Home address " << home_address << endl;
info << "Experience " << experience << endl;
info << "Phone number " << phone_number << endl;
info << "Number of hours worked " << number_of_hours_worked << endl;
info << "Cost of an hour of work " << cost_of_an_hour_of_work << endl;
info << "Wages " << wages() << endl;
info << "Bonus " << bonus() << endl;
info.close();
}
}
int wages()
{
return number_of_hours_worked * cost_of_an_hour_of_work;
}
float bonus()
{
if (experience >= 1)
{
if (experience >= 3)
{
if (experience >= 6)
{
if (experience >= 10)
{
return (float)number_of_hours_worked * cost_of_an_hour_of_work*13/100;
}
return (float)number_of_hours_worked * cost_of_an_hour_of_work * 7 / 100;
}
return (float)number_of_hours_worked * cost_of_an_hour_of_work * 5 / 100;
}
return (float)number_of_hours_worked * cost_of_an_hour_of_work * 3 / 100;
}
}
};
int main()
{
Employee One;
Employee Two("Veselov Oleg Borisovich", "Plumber", "Moscow, Leninsky prospect, building 5, apartment 16", 5, "+ 79883275603", 956, 300);
Employee Three("Smirnov Ivan Olegovich", "Driver", "Ivanovo, Thunderbolt street, building 17, apartment 83 ",13, "+ 79998235625", 3460, 380);
One.show();
Two.show();
Three.show();

return 0;
}
// помогал Евгений Смуров с инициализацией полей класса
Loading