Thursday, 28 January 2016

Solution of URI 1048 :: Salary Increase


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    double a,b,c;
    int d;
    char ch='%';
    scanf("%lf", &a);
    if(a>=0 && a<=400.00)
    {
        b=a*.15;
        c=a+b;
        d=15;
    }
    else if(a>=400.01 && a<=800)
    {
        b=a*.12;
        c=a+b;
        d=12;
    }
    else if(a>=800.01 && a<=1200)
    {
        b=a*.10;
        c=a+b;
        d=10;
    }
    else if(a>=1200.01 && a<=2000)
    {
        b=a*.07;
        c=a+b;
        d=7;
    }
    else if(a>2000)
    {
        b=a*.04;
        c=a+b;
        d=4;
    }
    printf("Novo salario: %.2lf\n",c);
    printf("Reajuste ganho: %.2lf\n",b);
    printf("Em percentual: %d %c\n",d,ch);
    return 0;
}

2 comments:

  1. #include
    int main()
    {
    float x,y,z;
    char ch='%';
    scanf("%f",&x);
    if(x>=0&&x<=400.00)
    {

    z=(x*15)/100;
    y=x+z;
    printf("Novo salario: %0.2f\n",y);
    printf("Reajuste ganho: %0.2f\n",z);
    printf("Em percentual: 15 %c\n",ch);
    }
    if(x>=400.01&&x<=800.00)
    {
    z=(x*12)/100;
    y=x+z;
    printf("Novo salario: %0.2f\n",y);
    printf("Reajuste ganho: %0.2f\n",z);
    printf("Em percentual 12 %c\n",ch);

    }
    if(x>=800.01&&x<=1200.00)
    {
    z=(x*10)/100;
    y=x+z;
    printf("Novo salario: %0.2f\n",y);
    printf("Reajuste ganho: %0.2f\n",z);
    printf("Em percentual 10 %c\n",ch);
    }
    if(x>=1200.01&&x<=2000.00)
    {
    z=(x*7)/100;
    y=x+z;
    printf("Novo salario: %0.2f\n",y);
    printf("Reajuste ganho: %0.2f\n",z);
    printf("Em percentual 7 %c\n",ch);
    }
    if(x>2000.00)
    {
    z=(x*4)/100;
    y=x+z;
    printf("Novo salario: %f\n",y);
    printf("Reajustr ganho: %f\n",z);
    printf("Em percentual 4 %c\n",ch);
    }
    return 0;
    }
    whats wrong with my code??

    ReplyDelete

Note: only a member of this blog may post a comment.