Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int fsum(int a, int b) {
  5. int sum = a + b;
  6. return sum;
  7. }
  8.  
  9. struct person {
  10. string name;
  11. double salary;
  12. double number_of_hours;
  13. double month_salary;
  14. };
  15.  
  16.  
  17. double calc_salary(double salary, double number_of_hours) {
  18. double sal = salary * number_of_hours;
  19. return sal;
  20. }
  21.  
  22. void display_person(person tmp) {
  23. cout <<"Name: "<< tmp.name<<endl;
  24. cout <<"Salary: "<<tmp.salary<<endl;
  25. cout <<"Number of hours: "<< tmp.number_of_hours<<endl;
  26. cout <<"Month salary: "<< tmp.month_salary<<endl;
  27. }
  28.  
  29. person fill_person(void) {
  30. person p1;
  31. cout << "Put your name: ";
  32. cin >> p1.name;
  33. cout << "Put your salary per hour: ";
  34. cin >> p1.salary;
  35. cout << "How many hours did you worked?: ";
  36. cin >> p1.number_of_hours;
  37. p1.month_salary=calc_salary(p1.salary, p1.number_of_hours);
  38. cout << p1.name << " your month salary is: " << calc_salary(p1.salary, p1.number_of_hours)<<endl;
  39. display_person(p1);
  40. return p1;
  41. }
  42.  
  43. double mean(person p[], int a) {
  44. double temp=0;
  45. for(int i = 0; i <= a; i++) {
  46. temp += p[i].month_salary;
  47. }
  48. return temp / a;
  49. }
  50.  
  51.  
  52. int main(){
  53. person p[3] = {
  54. {"first",4,4,16},
  55. {"second", 8, 8, 64},
  56. {"third", 5, 5, 25}
  57. };
  58. cout<<mean(p, 3);
  59. /*int a, b, sum;
  60. cin >> a;
  61. cin >> b;
  62. sum = fsum(a, b);
  63. cout << sum;*/
  64. //person p1=fill_person();
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement