Page 1 of 3

### 12342 - Tax Calculator

Posted: Wed Jun 06, 2012 3:52 pm
I am getting W A.

Code: Select all

``````/* Removed After AC*/
/* Thanks to Allah*/
``````

### Re: 12342 Tax Calculator

Posted: Wed Jun 06, 2012 11:03 pm
Don't use doubles at all in this problem.

### Re: 12342 Tax Calculator

Posted: Thu Jun 07, 2012 11:57 am
cut...

### Re: 12342 Tax Calculator

Posted: Thu Jun 07, 2012 6:11 pm
Use double for tax calculating and also ceil the value of tax after each tax calculation.

### Re: 12342 Tax Calculator

Posted: Fri Jun 08, 2012 1:30 am
Don't use doubles at all in this problem.

### Re: 12342 Tax Calculator

Posted: Mon Jun 11, 2012 7:02 pm
Cut...After AC....
thanks for help man........

### Re: 12342 Tax Calculator

Posted: Mon Jun 11, 2012 8:27 pm
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);

``````

### Re: 12342 Tax Calculator

Posted: Mon Jun 11, 2012 11:25 pm
Don't use doubles at all in this problem.

### Why WA 12342. help help....

Posted: Mon Jun 25, 2012 5:45 pm
I'm getting continuously WA, But why, help me please..

Code: Select all

``````#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<stdio.h>
#include<stdlib.h>

int main()
{
long int t, income, res, i, temp, flag;
double tax;
while(scanf("%ld",&t)==1)
{
for(i=1;i<=t;i++)
{
tax=0;
flag=1;
scanf("%ld", &income);
if(income<=180000)
tax=0;
else
{
income-=180000;
temp=income-300000;
if(temp<=0)
{
tax=(ceil)(income*10/100);
flag=0;
if(tax<2000)
tax=2000;
}
else if(income>0 && flag!=0)
{
tax+=(ceil)(300000*10/100);
income-=300000;
}

temp=income-400000;
if(temp<=0 && flag!=0)
{
tax+=(ceil)(income*15/100);
flag=0;
}
else if(income>0 && flag!=0)
{
tax+=(ceil)(400000*15/100);
income-=400000;
}

temp=income-300000;
if(temp<=0 && flag!=0)
{
tax+=(ceil)(temp*20/100);
flag=0;
}
else if(income>0 && flag!=0)
{
tax+=(ceil)(300000*20/100);
income-=300000;
}

if(income>0 && flag!=0)
{
tax+=(ceil)(income*25/100);
flag=0;
}

}
res=(long int)tax;
printf("%ld\n", res);
}
}
return 0;
}
``````

### Re: Why WA 12342. help help....

Posted: Tue Jun 26, 2012 12:40 am
Don't use doubles in this problem.

### Re: 12342 Tax Calculator

Posted: Mon Aug 27, 2012 9:25 am
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;
}

### Re: 12342 Tax Calculator

Posted: Mon Aug 27, 2012 8:42 pm
Don't use doubles at all in this problem.

### Re: 12342 Tax Calculator

Posted: Fri Mar 08, 2013 1:53 am
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;
}
``````

### Re: 12342 Tax Calculator

Posted: Fri Mar 08, 2013 2:11 am
Don't use floating point at all in this problem.

### Re: 12342 Tax Calculator

Posted: Thu Dec 12, 2013 9:27 pm
whats wrong with my program and why i don't use floating point??

Code: Select all

``````#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
unsigned long long int n,amount,check=1,tax;
//float tax;

cin>>n;
while(n>0)
{
tax=0;
cin>>amount;
if(amount<=180000)
{
tax=0;
}
else
{
amount=amount-180000;
if(amount<=300000)
{

tax=ceil((amount*10.0)/100);

}
else
{
tax=(300000*10.0)/100;
amount=amount-300000;
if(amount<=400000)
{
tax=ceil(tax+((amount*15.0)/100));
}
else
{
tax=(400000*15.0)/100;
amount=amount-400000;
if(amount<=300000)
{
tax=ceil(tax+((amount*20.0)/100));
}
else
{
tax=(300000*20.0)/100;
amount=amount-300000;
tax=ceil(tax+((amount*25.0)/100));
}
}
}

}
if(tax>0&&tax<2000)
{
tax=2000;
}

cout<<"Case "<<check<<": "<<tax<<endl;
check++;
n--;
}
return 0;
}``````