89 lines
2.2 KiB
C
89 lines
2.2 KiB
C
#include <stdio.h>
|
|
#include "libs.h"
|
|
//---------------------------------------------------------------------------------------
|
|
// Exercise 5
|
|
// ----------
|
|
//
|
|
// General : The program calculate the final salary by parameters.
|
|
//
|
|
// Input : 8 numbers
|
|
//
|
|
// Process : The program calculate the final salary by parameters.
|
|
//
|
|
// Output : The final salary
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : None
|
|
// Date : 12.09.2019
|
|
//---------------------------------------------------------------------------------------
|
|
void main(void)
|
|
{
|
|
float salary,
|
|
vetek,
|
|
hours,
|
|
kids,
|
|
temp_kids,
|
|
temp_hours,
|
|
ty,
|
|
tb,
|
|
t160,
|
|
t175,
|
|
final_salary;
|
|
|
|
printf("Enter salary: ");
|
|
scanf("%f", &salary);
|
|
printf("Enter vetek: ");
|
|
scanf("%f", &vetek);
|
|
printf("Enter hours: ");
|
|
scanf("%f", &hours);
|
|
printf("Enter kids: ");
|
|
scanf("%f", &kids);
|
|
printf("Enter ty: ");
|
|
scanf("%f", &ty);
|
|
printf("Enter tb: ");
|
|
scanf("%f", &tb);
|
|
printf("Enter t160: ");
|
|
scanf("%f", &t160);
|
|
printf("Enter t175: ");
|
|
scanf("%f", &t175);
|
|
|
|
temp_kids = kids;
|
|
temp_hours = hours;
|
|
final_salary = salary;
|
|
|
|
if (vetek > TEN)
|
|
{
|
|
final_salary += (int)((double)final_salary * ONE_HUNDRED_AND_TEN_PERCENT);
|
|
}
|
|
|
|
temp_kids -= THREE;
|
|
if (temp_kids > ZERO)
|
|
{
|
|
if (temp_kids > THREE)
|
|
{
|
|
final_salary += ((temp_kids - THREE) * tb) +
|
|
(temp_kids - (temp_kids - THREE)) * ty;
|
|
}
|
|
else
|
|
{
|
|
final_salary += (temp_kids * ty)
|
|
}
|
|
}
|
|
|
|
temp_hours -= ONE_HUNDRED_SIXTY;
|
|
if (temp_hours > ZERO)
|
|
{
|
|
if (temp_hours > FIFTEEN)
|
|
{
|
|
final_salary += ((temp_hours - FIFTEEN) * t175) +
|
|
(temp_hours - (temp_hours - FIFTEEN)) * t160;
|
|
}
|
|
else
|
|
{
|
|
final_salary += (temp_hours * t160);
|
|
}
|
|
}
|
|
|
|
printf("The salary: %f\n", final_salary);
|
|
} |