Thursday 28 January 2016

Solution of URI 1051 :: Taxes


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;
    scanf("%lf", &a);
    if(a>=0 && a<=2000)
        printf("Isento\n");
    else if(a>=2000.01 && a<=3000)
    {
        a-=2000;
        b= a*.08;
        printf("R$ %.2lf\n",b);
    }
    else if(a>=3000.01 && a<=4500)
    {
        a-=3000;
        b= a*.18+80;
        printf("R$ %.2lf\n",b);
    }
    else
    {
        a-=4500;
        b= a*.28+350;
        printf("R$ %.2lf\n",b);
    }
    return 0;
}

9 comments:

  1. bhaiya ei code ta te shomoshha ki bujtesi na!! output is same but URI is not accepting-
    double a,b;
    scanf("%lf",&a);
    if(a>=2000.01 && a<=3000.0){
    b=((a-2000)*.08);
    printf("%.2lf\n",b);
    }
    else if(a>=3000.01 && a<=4500.0){
    b=((a-3000)*0.18);
    printf("R$ %.2lf\n",80+b);
    }
    else if(a>4500.0){
    b=((a-4500)*.28);
    printf("R$ %.2lf\n",b+350);
    }
    else if(a>=0 && a<=2000){
    printf("Insento\n");
    }

    ReplyDelete
  2. you wrote "Insento" in the last printf,the correct is "Isento"

    ReplyDelete
  3. How you get 80, 350 in 2nd & 3rd else if condition?

    ReplyDelete
  4. 80 comes from 1000*0.08 and 350 is 80 plus 270 which comes from 1500*0.18
    if the number is greater than 4500 then for sure it has the 8% tax on 1000 which is the difference between the two limits as 3000-2000.The same applies for the 270 as 4500-3000 is 1500 and the tax applied is 0.18.
    Hope that was helpful

    ReplyDelete
  5. When I was searching something about tax, I found your blog, after reading your blog about Accounting; I have gained a lot of information. Also I would like to introduce my company, Singapore Tax Accounting which is also providing complete tax solution and Business Advisory in Singapore

    ReplyDelete
  6. solution er logic ta bujlam na ,,,,

    ReplyDelete
  7. Code ta oshadharon kintu..

    "a-=3000;"

    Ei line ta keno bujhlam na...???

    ReplyDelete

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