In: Computer Science
employee_status years_of_service percent_raise
Full-time less than 5 years 4.0
Full-time 5 years or more 5.0
Part-time less than 5 years 2.5
Part-time 5 years or more 3.0
If employee_status value is ‘F’, the employee is full-time; if it is ‘P’, he or she is a part-time employee. Write a nested if statement that computes the new salary of the employee given his or her employee_status, years_of_service and salary.
C code:
#include<stdio.h>
int main(){
char employee_status;
float salary;
int year_of_service;
printf("Please enter employee status (F or P): ");
scanf("%c",&employee_status);
printf("Please enter salary of the employee: ");
scanf("%f",&salary);
printf("Please enter the years of service of the employee( in
years ): ");
scanf("%d",&year_of_service);
if(employee_status == 'F'){ //If employee status is full
time
if (year_of_service < 5){
salary = salary*1.04; //4 % raise
}
else{
salary = salary*1.05; //5 % raise
}
}
else{
if (year_of_service < 5){
salary = salary*1.025; //2.5 % raise
}
else{
salary = salary*1.03; //3 % raise
}
}
printf("The increase salary of employee is now:
%.2f",salary);
return 0;
}
Output: