Computer Science Canada

please help me with federal income tax problem

Author:  Misha [ Mon Oct 04, 2004 7:31 pm ]
Post subject:  please help me with federal income tax problem

hi, i am new to turing and i need help with an easy question. my teacher assigned us a problem that goes like this

Write a program to calculate the amount of Federal Income Tax owed by the user. Federal Income Tax is calculated the following way: If you earn less than $27000 you pay 17% of your income. If you earn between $27000 and $54500 then you pay 17% on the first $27000 and then 24% on the amount over $27000. If you earn more than $54500 then you pay 17% on the first $27000, 24% on the next $27500 and 29% on the amount over $54500.

please help
thanx

Author:  AsianSensation [ Mon Oct 04, 2004 7:35 pm ]
Post subject: 

well, please show me what you have done so far, it's not our habit to give out free code and such.

I do suggest the usage of case or if statements, they are very helpful for this problem.

Also it helps if you know some basic math. Such as 17% of something is the same as multiplying by 0.17.

Author:  Misha [ Mon Oct 04, 2004 7:53 pm ]
Post subject: 

this is what i have so far but i don't know if it is right because it keeps saying error and since i'm new to turing i don't understand why. as well if you tell me why please do it the easy way because we didn't learn the hard way and are teacher doesn't want us to do that.

code:


%------------------------------------------
% federal tax
% Date Written Oct 4
%
% input: how much money the user earn
% output: amount of money user has to pay for federal income tax
% Process: ask user how much money the user makes
%-----------------------------------------

% Declare Variables
var money : real

% Ask for input
put "how much money do you make a year? "
get money
if money <= 27000 then
money * 0.17
end if
if money >27000 then
money * 0.17
end if
if money >54500


thanx

Author:  AsianSensation [ Mon Oct 04, 2004 8:05 pm ]
Post subject: 

well, you are doing something like
code:
money * 0.17
, which yields a value only. You need something to hold this value.

So you could declare another variable, and call it Taxes, and make it real. Then, you assign Taxes your calculated value.

So instead of

code:
money * 0.17
, it should be
code:
Taxes := money * 0.17

Author:  Paul [ Mon Oct 04, 2004 8:10 pm ]
Post subject: 

its money+money*taxrate

Author:  Misha [ Mon Oct 04, 2004 8:30 pm ]
Post subject: 

okay i did wat you told me but the program doesn't do anything and i said that i don't know how to do any of the other stuff. this is wat i have
code:

%------------------------------------------
% federal tax
% Date Written Oct 4
%
% input: how much money the user earn
% output: amount of money user has to pay for federal income tax
% Process: ask user how much money the user makes
%-----------------------------------------

% Declare Variables
var money : real
var taxes : real

% Ask for input
put "how much money do you make a year? "
get money
if money <= 27000 then
taxes := money * 0.17
end if
if money >27000 then
taxes := money * 0.17
end if


please help
thanx

Author:  wtd [ Mon Oct 04, 2004 8:31 pm ]
Post subject: 

code:
if money <= 27000 then
   money * 0.17
end if
if money >27000 then
   money * 0.17
end if


This should be:

code:
if money <= 27000 then
   money * 0.17
elsif money >27000 then
   money * 0.17
end if


The way you have it written, both would have been run. When you use "else" and "elsif", you ensure that only one possibility can be judged true.

Author:  AsianSensation [ Mon Oct 04, 2004 8:33 pm ]
Post subject: 

well, you are kinda missing a couple of put statements. How are you expecting outputs on the screen if you do not use put to output your results?

do something like this:

code:
put "You need to pay", taxes, " amount of money"

Author:  Misha [ Mon Oct 04, 2004 8:47 pm ]
Post subject: 

sorry again, but this program isn't still finished and i tryed finishing it but it keeps screwing up.

please help

thanx

Author:  Paul [ Mon Oct 04, 2004 9:25 pm ]
Post subject: 

and you don't have to say "I'm new to turing" everytime you ask for help, its not as if we won't help you if you don't say that.

Author:  Misha [ Mon Oct 04, 2004 9:42 pm ]
Post subject: 

i am new to turing and i say that because when i don't say it people give me these hard codes that i don't understand. anyways you didn't help me, so please do.

Author:  Cervantes [ Tue Oct 05, 2004 5:32 pm ]
Post subject: 

A wee bit aggressive in our asking for help, are we?

You outlined the way taxes work very nicely. Now, using two variables, one for the persons income and another for the amount of tax they owe, write the code. Use if statements, and simply follow what the question is. Use logic, and you'll be fine.

If you still have problems, show us the revised code, not the code you posted at first.

Author:  Paul [ Tue Oct 05, 2004 5:34 pm ]
Post subject: 

Misha wrote:
i am new to turing and i say that because when i don't say it people give me these hard codes that i don't understand. anyways you didn't help me, so please do.

actually, I did post above, AS just got there b4 me Razz
but if by helping you mean posting code for you Confused then I suppose I didn't

Author:  henry89 [ Sat Dec 08, 2018 1:39 pm ]
Post subject:  Re: please help me with federal income tax problem

Hello,


Misha wrote:

this is what i have so far but i don't know if it is right because it keeps saying error and since i'm new to turing i don't understand why. as well if you tell me why please do it the easy way because we didn't learn the hard way and are teacher doesn't want us to do that.

code:


%------------------------------------------
% federal tax
% Date Written Oct 4
%
% input: how much money the user earn
% output: amount of money user has to pay for federal income tax
% Process: ask user how much money the user makes
%-----------------------------------------

% Declare Variables
var money : real

% Ask for input
put "how much money do you make a year? "
get money
if money <= 27000 then
money * 0.17
end if
if money >27000 then
money * 0.17
end if
if money >54500


thanx


Thanks for creating a program for income tax calculate that I have uses this code & this code is very useful.

Thanks again!


: