Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------------------------------------------------------------------------------------
- // Exercise 8
- // ----------
- //
- // General : The program will get details about the employee and calculate his salary with them.
- //
- // Input : Base salary, seniority, number of children, working hours, and bonuses.
- //
- // Process : The program considers all the known details about the employee, and calculates his salary by them and by the rules of the company.
- //
- // Output : Prints the employee salary.
- //
- //------------------------------------------------------------------------------------------------------------------------------
- // Programmer: Ohad Ozcohen
- // Date: 9.9.2016
- //------------------------------------------------------------------------------------------------------------------------------
- #include <stdio.h>
- #define seniority_add 0.1
- #define seniority_bonuos_time 10
- void main(void)
- {
- float base_salary;
- float seniority;
- float num_of_children;
- float working_hours;
- float TY, TB, T160, T175;
- printf("Please enter your base salary: ");
- scanf_s("%f", &base_salary);
- printf("Please enter your seniority: ");
- scanf_s("%f", &seniority);
- printf("Please enter number of children:");
- scanf_s("%f", &num_of_children);
- printf("Please enter the number of hours: ");
- scanf_s("%f", &working_hours);
- printf("Please enter your TY: ");
- scanf_s("%f", &TY);
- printf("Please enter your TB: ");
- scanf_s("%f", &TB);
- printf("Please enter your T160: ");
- scanf_s("%f", &T160);
- printf("Please enter your T175: ");
- scanf_s("%f", &T175);
- if (seniority > seniority_bonuos_time)
- {
- base_salary = seniority_add*base_salary + base_salary;
- }
- if (num_of_children > 3)
- {
- base_salary = (6 - num_of_children > 0)*((int)num_of_children % 3)*TY + base_salary;
- base_salary = (num_of_children - 6 > 0)*(num_of_children - 6)*TB + base_salary;
- }
- if (working_hours > 160)
- {
- int extra_hours = working_hours - 160;
- base_salary = (extra_hours - 15 > 0)*(extra_hours - 15)*T175 + (extra_hours - 15 > 0) * 15 * T160 + base_salary;
- base_salary = (extra_hours - 15 < 0)*(extra_hours - 15)*T160*(-1) + base_salary;
- }
- printf("your salary is %.2f", base_salary);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement