jeudi 13 août 2020

There is an error in the if statement to calculate work year bonus [closed]

This code is to calculate the gross remuneration of a company salesman. But the if statement for calculating additional allowance if the service years is more than 4 if not properly working I want to find the error here.

#include<stdio.h>
int main()
{
    int Basic,GrossRem,WorkInBonus,MonthlyBonus,sales,Years,AddAllow;
    char workIn;

    printf ("Enter basic salary : ");
    scanf ("%d",&Basic);
    printf ("Enter years of service : ");
    scanf ("%d",&Years);
    printf ("Enter monthly sales : ");
    scanf ("%d",&sales);
    printf ("Enter 'L' if work in Lima, or N if not : ");
    scanf ("%s",&workIn);

    printf ("\n\n");

    if (sales < 1000)
        MonthlyBonus=(sales*10)/100;
    else if (sales < 2000)
        MonthlyBonus=(sales*15)/100;
    else
        MonthlyBonus=(sales*20)/100;
    printf ("Monthly sales bonus : %d \n",MonthlyBonus);

    if (Years > 4)
        AddAllow=Basic*10/100;
    else
        AddAllow=0;
    printf ("Work year bonus : %d \n",AddAllow);

    if (workIn=='L')
        WorkInBonus=500;
    else
        WorkInBonus=0;
    printf ("Work in Lima bonus : %d \n",WorkInBonus);

    GrossRem = AddAllow+WorkInBonus+MonthlyBonus+Basic;
    printf ("Gross remuneration : %d \n",GrossRem);

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire