Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Author Message
Misha

Posted: 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.

thanx

AsianSensation

Posted: Mon Oct 04, 2004 7:35 pm   Post subject: (No 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.
Misha

Posted: Mon Oct 04, 2004 7:53 pm   Post subject: (No 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
AsianSensation

Posted: Mon Oct 04, 2004 8:05 pm   Post subject: (No 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.

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

Posted: Mon Oct 04, 2004 8:10 pm   Post subject: (No subject)

its money+money*taxrate
Misha

Posted: Mon Oct 04, 2004 8:30 pm   Post subject: (No 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

thanx
wtd

Posted: Mon Oct 04, 2004 8:31 pm   Post subject: (No 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.
AsianSensation

Posted: Mon Oct 04, 2004 8:33 pm   Post subject: (No 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"

Misha

Posted: Mon Oct 04, 2004 8:47 pm   Post subject: (No subject)

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

thanx
Paul

Posted: Mon Oct 04, 2004 9:25 pm   Post subject: (No 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.
Misha

Posted: Mon Oct 04, 2004 9:42 pm   Post subject: (No 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.
Cervantes

Posted: Tue Oct 05, 2004 5:32 pm   Post subject: (No 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.
Paul

Posted: Tue Oct 05, 2004 5:34 pm   Post subject: (No 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
but if by helping you mean posting code for you then I suppose I didn't
henry89

Posted: 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!
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 14 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: