1. Engineering
  2. Computer Science
  3. programming language c need help to convert the code inside...

Question: programming language c need help to convert the code inside...

Question details

(Programming language C) Need help to convert the code inside if and else statements into a method and call it

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void)
{
int employeeNumber;
double hourlySalary;
double weeklyTime;
double netPay;
double regularPay;
double overtimePay;
  
puts("Welcome to \"TEMPLE HUMAN RESOURCES\"");
  
   printf("\n\tEnter Employee Number: ");
   scanf("%d", &employeeNumber);
  
if(employeeNumber>0){
printf("\tEnter Hourly Wage: ");
   scanf("%lf", &hourlySalary);

   if(hourlySalary>0){
   printf("\tEnter Weekly Wage: ");
   scanf("%lf", &weeklyTime);
  
   if(weeklyTime>0){
if(weeklyTime<=40){
  
puts("\t================================");
netPay = regularPay = weeklyTime*hourlySalary;
printf("\tEmployee #: \%d \n" , employeeNumber);
printf("\tHourly Salary: $\%lf \n" , hourlySalary);
printf("\tWeekly Time: \%f \n" , weeklyTime);
printf("\tRegular Pay: $\%f \n" , regularPay);
printf("\tOvertime Pay: $0 \n");
printf("\tNet Pay: $\%lf \n" , netPay);
puts("\t================================");
}
else{
  
puts("\t================================");
  
double timeReminder = fmod(weeklyTime,40);
regularPay = 40*hourlySalary;
overtimePay = (timeReminder)*(hourlySalary*1.5);
netPay = overtimePay + regularPay;
  
printf("\tEmployee #:",employeeNumber);
printf("\tHourly Salary: $\%.1f \n",hourlySalary);
printf("\tWeekly Time: \%.1f \n", weeklyTime);
printf("\tRegular Pay: $\%.1f \n",regularPay);
printf("\tOvertime Pay: $\%.1f \n",overtimePay);
printf("\tNet Pay: $\%.1f \n",netPay);
puts("\t================================");
}
   }else{
   puts("\n\tThis is not a weekly time.");
   puts("\tPlease run the program again");
   }
   }else{
   puts("\n\tThis is not a valid hourly salary amount.");
   puts("\tPlease run the program again");
   }
}
else{
puts("\n\tThis is not a valid Employee Number.");
puts("\tPlease run the program again");
}
   puts("Thank you for using \"TEMPLE HUMAN RESOURCES\"");
exit(0);

}


Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution