Write a C Program to Calculate the commission of a salesman considering three regions X,Y,Z depending on the sales amount as follows:
FOR AREA CODE - X
| sales amount | Commission |
| -------- | -------- |
| <1000 | 10% |
| <5000 | 12% |
| >=5000 | 15% |
-----------------------------
FOR AREA CODE - Y
| sales amount | Commission |
| -------- | -------- |
| <15000 | 10% |
| <7000 | 12% |
| >=7000 | 15% |
-----------------------------
FOR AREA CODE - Z
| sales amount | Commission |
| -------- | -------- |
| <12000 | 10% |
| <5600 | 12% |
| >=6500 | 15% |
-----------------------------
I take the input as a character for the area code and read it, then I take the input for the sales amount and commission to calculate the commission as a float and read, after that, I check the condition like this -
float amt, comission;
char area;
printf("Area code is - 'X','Y' & 'Z'");
printf("\nEnter Your Area Code: ");
scanf("%c", &area);
printf("Enter Amount: ");
scanf("%f", &amt);
if (area == 'X' && amt < 1000)
{
printf("You got 10%% Commission");
comission = ((100 - 10) * amt) / 100;
printf("After Commision The Slaes amount is: %6.2f", comission);
if (amt >= 1000 && amt < 5000)
{
printf("You got 12%% Commission");
comission = ((100 - 12) * amt) / 100;
printf("After Commision The Slaes amount is: %6.2f", comission);
}
if (amt >= 5000)
{
printf("You got 15%% Commission");
comission = ((100 - 15) * amt) / 100;
printf("After Commision The Slaes amount is: %6.2f", comission);
}
}
same codes for Y and Z using else if() condition
.
But I did not get the expected output. after read the values my program automatically terminates.