Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int fsum(int a, int b) {
- int sum = a + b;
- return sum;
- }
- struct person {
- string name;
- double salary;
- double number_of_hours;
- double month_salary;
- };
- double calc_salary(double salary, double number_of_hours) {
- double sal = salary * number_of_hours;
- return sal;
- }
- void display_person(person tmp) {
- cout <<"Name: "<< tmp.name<<endl;
- cout <<"Salary: "<<tmp.salary<<endl;
- cout <<"Number of hours: "<< tmp.number_of_hours<<endl;
- cout <<"Month salary: "<< tmp.month_salary<<endl;
- }
- person fill_person(void) {
- person p1;
- cout << "Put your name: ";
- cin >> p1.name;
- cout << "Put your salary per hour: ";
- cin >> p1.salary;
- cout << "How many hours did you worked?: ";
- cin >> p1.number_of_hours;
- p1.month_salary=calc_salary(p1.salary, p1.number_of_hours);
- cout << p1.name << " your month salary is: " << calc_salary(p1.salary, p1.number_of_hours)<<endl;
- display_person(p1);
- return p1;
- }
- double mean(person p[], int a) {
- double temp=0;
- for(int i = 0; i <= a; i++) {
- temp += p[i].month_salary;
- }
- return temp / a;
- }
- int main(){
- person p[3] = {
- {"first",4,4,16},
- {"second", 8, 8, 64},
- {"third", 5, 5, 25}
- };
- cout<<mean(p, 3);
- /*int a, b, sum;
- cin >> a;
- cin >> b;
- sum = fsum(a, b);
- cout << sum;*/
- //person p1=fill_person();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement