Hi
I writing a salary calculation with C with different pay range, but it is keep show me the error or can't proceed to the next line when come to if else method.
I try to make it output like this
Code:
#include <stdio.h>
#include <math.h>
int main()
{
char workerName[100];
char workerNric[14];
char payCategory[2];
float totalHour;
float a1 = 5;
float a2 = 7;
float m1 = 10;
float m2 = 15;
float bb = 20;
float grossPay, overTime, nettPay;
printf("Name \t:\t");gets(workerName);
printf("NRIC \t:\t");gets(workerNric);
printf("Category A1, A2, M1, M2 or BB \t:\t");gets(payCategory);
printf("Total Hours\t:\t");
scanf("%f",&totalHour);
printf("\n\t\tSyarikat Smart Store Hypermarket Sdn. Bhd.");
printf("\n\t\t==========================================");
printf("\nName : %s", workerName);
printf("\nNRIC : %s", workerNric);
printf("\nCategory : %s", payCategory);
printf("\nTotal Hours : %.2f", totalHour);
#define maxHour 44
if(*payCategory == a1)
{
if(totalHour <= 44)
{
grossPay = 44 * a1;
overTime = 0;
nettPay = grossPay;
}
else if(totalHour >= 44)
{
grossPay = 44 * a1;
overTime = ((totalHour - 44) * a1 * 1.5);
nettPay = grossPay + overTime;
}
}
printf("\nGross Pay : RM %.2f", grossPay);
printf("\nOver Time : RM %.2f", overTime);
printf("\nNett Pay : RM %.2f", nettPay);
return 0;
}