12342 - Tax Calculator

All about problems in Volume 123. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 12342 - Tax Calculator

Post by lighted » Sun Oct 26, 2014 9:30 am

Use double instead of float. :)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 12342 - Tax Calculator

Post by lighted » Sun Oct 26, 2014 5:39 pm

I already got accepted with your code by changing float to double. And i see that you too. :)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Xoros
New poster
Posts: 3
Joined: Fri Jan 16, 2015 2:31 pm

Re: 12342 - Tax Calculator

Post by Xoros » Fri Jan 16, 2015 2:47 pm

Please help, I keep getting WA even if the output is the same in uDebug
Thank you in advance! :3

Code: Select all

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

int main()
{
	int x;
	int i = 1;
	int y;
	double nTax = 0.0;

	scanf("%d", &x);

	while(x)
	{
		scanf("%d", &y);
		switch(y > 180000)
		{
			case 1: if(y - 180000 < 300000)
				{	y -= 180000;
					nTax += (y * .1);
				}
				else
				{	nTax += 30000;
					y -= 180000;
					if(y - 300000 < 400000)
					{	y -= 300000;
						nTax += (y * .15);
					}
					else
					{
						nTax += (400000 * .15);
						y -= 300000;
						if(y - 300000 < 300000)
						{	y -= 400000;
							nTax += (y * .2);
						}
						else
						{	
							nTax = nTax + (300000 * .2);
							y -= 400000;
							if(y - 300000 > 0)
							{	y -= 300000;
								nTax +=  (y * .25);
							}
						}
							
					}
				
				}	
			
			
			case 0: printf("Case %d: ", i);
			
				if(nTax < 2000 && nTax > 0)
					printf("2000\n");
				else
					printf("%.0f\n",ceil(nTax));
				
			
		}

		nTax = 0.0; i++; x--;	
	}
	return 0;
}




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

Re: 12342 - Tax Calculator

Post by brianfry713 » Sat Jan 17, 2015 1:11 am

Try solving it without using floating point.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 123 (12300-12399)”