## 12342 Tax Calculator

Moderator: Board moderators

### 12342 Tax Calculator

I am getting W A.
Code: Select all
`/* Removed After AC*//* Thanks to Allah*/`
Last edited by uvasarker on Thu Jun 07, 2012 6:09 pm, edited 1 time in total.
uvasarker
Learning poster

Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm

### Re: 12342 Tax Calculator

Don't use doubles at all in this problem.
brianfry713
Guru

Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 12342 Tax Calculator

cut...
Last edited by mahade hasan on Mon Jun 11, 2012 7:01 pm, edited 1 time in total.
we r surrounded by happiness
need eyes to feel it!

Learning poster

Posts: 64
Joined: Thu Dec 15, 2011 3:08 pm

### Re: 12342 Tax Calculator

Use double for tax calculating and also ceil the value of tax after each tax calculation.
uvasarker
Learning poster

Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm

### Re: 12342 Tax Calculator

Don't use doubles at all in this problem.
brianfry713
Guru

Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 12342 Tax Calculator

Cut...After AC....
thanks for help man........
Last edited by mahade hasan on Wed Jun 13, 2012 7:41 am, edited 1 time in total.
we r surrounded by happiness
need eyes to feel it!

Learning poster

Posts: 64
Joined: Thu Dec 15, 2011 3:08 pm

### Re: 12342 Tax Calculator

do look like this
Code: Select all
`            double rest=0.0, tmp=0.0, tax=0.0;            tmp=n-180000;            n=n-180000;            if(tmp>300000){                tax+=0.1*300000.0;                n=n-300000.0;                tmp=n;            }            else if(n>0){                tax+=0.1*tmp;                n=n-300000.0;                tmp=n;            }            tax=(ceil)(tax);            //printf("tax= %.0lf\n",tax);//tmp1=n-400000;            if(tmp>400000){                tax+=0.15*400000.0;                n=n-400000;                tmp=n;            }            else if(n>0){                tax+=0.15*tmp;                n=n-400000;                tmp=n;            }            //printf("tax= %.0lf\n",tax);//tmp2=n-300000;            tax=(ceil)(tax);`
uvasarker
Learning poster

Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm

### Re: 12342 Tax Calculator

Don't use doubles at all in this problem.
brianfry713
Guru

Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 12342 Tax Calculator

Getting WA for this code:

#include <stdio.h>
#include <math.h>

int main()
{
int i,n,money,check;
double tax,a;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
check=tax=0;
scanf("%d",&money);
if(money-180000>0)
{
money=money-180000;
if(money-300000<=0)
{
a=((double)(money*10)/100);
a=ceil(a);
tax=tax+a;
}
else
{
a=((double)(300000*10)/100);
a=ceil(a);
tax=tax+a;
money=money-300000;
if(money-400000<=0)
{
a=((double)(money*15)/100);
a=ceil(a);
tax=tax+a;
}
else
{
a=((double)(400000*15)/100);
a=ceil(a);
tax=tax+a;
money=money-400000;
if(money-300000<=0)
{
a=((double)(money*20)/100);
a=ceil(a);
tax=tax+a;
}
else
{
a=((double)(300000*20)/100);
a=ceil(a);
tax=tax+a;
money=money-300000;
if(money>0)
{
a=((double)(money*25)/100);
a=ceil(a);
tax=tax+a;
}
}
}
}
}
else
{
printf("Case %d: %.0lf\n",i,tax);
check++;
}
if(check==0)
{
if(tax>0 && tax<=2000)
{
tax=2000;
printf("Case %d: %.0lf\n",i,tax);
}
else printf("Case %d: %.0lf\n",i,tax);
}
}
return 0;
}
naam nai
New poster

Posts: 1
Joined: Mon Aug 27, 2012 9:20 am

### Re: 12342 Tax Calculator

Don't use doubles at all in this problem.
brianfry713
Guru

Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 12342 Tax Calculator

I am getting WA. can anyone help me?

Code: Select all
`#include <stdio.h>#include <math.h>int percent(long long ammount,int pcnt){    int result=0;    result = ceil((float)(ammount*pcnt)/100);    return result;}int tax_calculator(long long ammount){    int result=0;    if(ammount>180000){        ammount = ammount-180000;        if(ammount>=300000){            result = percent(300000,10);             //printf("res: %d\n",result);            ammount = ammount - 300000;            if(ammount>=400000){                result+= percent(400000,15);                 //printf("res: %d\n",result);                ammount = ammount-400000;                if(ammount>=300000){                    result+= percent(300000,20);                     //printf("res: %d\n",result);                    ammount = ammount-300000;                    if(ammount>0){                        result+= percent(ammount,25);                        //printf("res: %d\n",result);                    }                }else{                    result+= percent(ammount,20);                    //printf("res: %d\n",result);                    return result;                }            }else{                result+= percent(ammount,15);                //printf("res: %d\n",result);                return result;            }        }else{            result+= percent(ammount,10);            //printf("res: %d\n",result);            return result;        }    }    else{        return 0;    }    return result;}int main(){    int cases, caseno=0,result=0;    long long ammount;    scanf("%d",&cases);    while(cases--){        scanf("%lld",&ammount);        result = tax_calculator(ammount);        if(result<2000 && result!=0){            result=2000;        }        printf("Case %d: %d\n",++caseno,result);    }    return 0;}`
alamin.opu10
New poster

Posts: 1
Joined: Fri Mar 08, 2013 1:49 am

### Re: 12342 Tax Calculator

Don't use floating point at all in this problem.
brianfry713
Guru

Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA