In: Computer Science
You are asked to compute weekly payment for an
employee working at CubixLabs. The
CubixLabs has a policy such that, if the employee works less than
50 hours in a week then
he/she will get payment as per the given payment rate, that is
amount per hour. Otherwise (in
all other conditions) he/she will get payment which is 50 x payment
rate. Develop program
using C language
In the above question, we need to process salary of an employee.
In the given question, let us understand the given statements,
We need to compute weekly payment.
if employee works less than 50 hrs then we will process according to the number of hours he/she worked * payment rate
and if employee works more than or equal to 50 hrs then the payment will be 50 * payment rate.
#include<stdio.h>
#include<conio.h>
int main()
{
float payment_rate;
float number_of_hours;
float net_salary;
clrscr();
printf("Enter Payment Rate: ");
scanf("%f",&payment_rate);
printf("Enter number of hours worked in a week: ");
scanf("%f",&number_of_hours);
if(number_of_hours < 50)
{
net_salary=number_of_hours * payment_rate;
}
else
{
net_salary=50 * payment_rate;
}
printf("Net Salary calculated in a week: %f",net_salary);
getch();
return 0;
}
Let us see the code, input and output generated by the compiler.
Now let us understand the input and output
In the above input/output, number of hours worked is less than 50, so we will simply calculate net salary by payment rate * number of hours worked in week.
In above example, number of hours worked is 60 which is more than 50 so we will calculate net salary by payment rate * 50