I know it's a simple question but I'm a beginner and I am having a difficulty in loops. The program below assigned to compute the salary of employees but I'm having a problem with loops it didn't ask if the user wants to repeat or to stop the transaction instead it proceeds in repeating and just printing the question.
#include <stdio.h>
#include <stdlib.h>
//this program will compute the salary of employees
//employees are either parttime or fulltime
int main(int argc, char *argv[]) {
char empType, yn;
double hourlyRate, hoursWorked;
double regPay, otHours, otPay;
double grossIncome;
do{
printf("Welcome to Payroll Program \n");
printf("Enter employee type: [f/F - Fulltime, p/P - Part-time]: ");
scanf("%c",&empType);
if (empType == 'f' || empType == 'F'){
printf("Enter regular pay: ");
scanf("%lf",®Pay);
hourlyRate = regPay/40;
printf("Enter overtime hours: ");
scanf("%lf", &otHours);
if (otHours > 0 )
{
otPay = otHours * (hourlyRate * 1.25);
grossIncome = regPay+otPay;
printf("You are a full-time employee. \nYour gross income is %lf\n", grossIncome);
}else{
grossIncome = regPay;
printf("You are a full-time employee.\nYour gross income is %lf\n", grossIncome);
}
}
if (empType == 'p' || empType == 'P'){
printf("Enter your hours worked: ");
scanf("%lf",&hoursWorked);
printf("Enter hourly rate: ");
scanf("%lf", &hourlyRate);
grossIncome = hoursWorked * hourlyRate;
printf("You are a part-time employee. \nYour gross income is %lf\n", grossIncome);
}
printf("Try Again? (Y/N): \n");
scanf("%c",&yn);
}
while (yn == 'y');
return 0;
}