wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes urgent help needed for assignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "urgent help needed for assignment" Watch "urgent help needed for assignment" New topic
Author

urgent help needed for assignment

sam mukhtar
Greenhorn

Joined: Mar 21, 2004
Posts: 12
o.k i'm basically on my knees here, i have no idea where to start, can anyone give me some hints i.e what topics i should be reading to do this assignment
Specification
Write a program to calculate the tax of an employee. The program should
prompt for a salary and age, and work out the required tax from this data.
These two items will be whole numbers, however the resulting tax calculation
may be a floating-point number.
If the employee is aged 50 or over, their taxable income reduces by 10%.
Taxation Rates
The taxation rates and thresholds are the following:
Taxable Income Tax Calculation
$0 - $6,000 No tax
$6,001 - $21,600 17% on each $1 over $6000
$21,601 - $52,000 $2,652 plus 30% on each $1 over $21,600
$52,001 - $62,500 $11,772 plus 42% on each $1 over $52,000
$62,501 + $16,182 plus 47% on each $1 over $62,500
Valarie Brandt
Greenhorn

Joined: Oct 03, 2003
Posts: 24
I would start by coding the gets and sets for the employees wage and age and then you could either do a nested if for the age and then an array to determine the correct taxes
if age<50
(do this array)
else if age=>50
(do this array
I know that is kind of a simplistic start but maybe it'll hlep to get the ball rolling for you
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
Sam,
First you will need to set up a BufferedReader to get the user input. Look at Integer.parseInt() to convert the user input for wage and age into whole numbers you can work with.
Once you have the two values, check the age. If the age is greater than or equal to 50, multiply the wage by 0.9. Then you can use a switch statement or an if, else if construct to find which tax calculation to use. If you use the if, else if, be sure to work from the maximum value down. If you use switch, don't forget to include break statements.
When you have some code, if you are still having problems, post it and we'll see what we can do.

Tom Blough


Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
sam mukhtar
Greenhorn

Joined: Mar 21, 2004
Posts: 12
thanks valarie and tom, you both are legends. i will keep you updated.
cheers
sam mukhtar
Greenhorn

Joined: Mar 21, 2004
Posts: 12
Tim, this is what i have so far, i can't think of how to do the over 50 part with the 10 per cent reduction:
public static void main (String[] args) throws IOException
{
finale int income
finale double tax
finale int age
// create a text input stream
BufferedReader stdin = new BufferedReader (new
InputStreamReader (System.in));
String message;
// read a line of text
System.out.print("Enter the employee’s taxable income:");
message = stdin.readLine();
// display the line of text
System.out.println("Your input was: " + message);
System.out.print("Enter the employee’s age:");
message = stdin.readLine();
System.out.println("Your input was: " + message);
}

if age<50
switch ( income)
case 1:
income =<6000
tax = 0
break;
case 2:
income =< 21600 && => 6001
tax = 0.17(income-6000)
brekae;
case 3:
income =< 52000 && => 21601
tax = 0.3(income-21601)+2652
breake;
case 4:
income =< 62500 && => 51001
tax = 0.42(income-52000)+11,772
break;
case 5:
income => 62501
tax = 0.47(income-62501)+16182
break;

else if age=>50
P.S: i would really appreciate your help on that..thanks
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
I like this kind of challenging program... I do knoe that it is not that good for greenhorns to ask for the complete program from ranchers here... Here I come up with almost complete program, according to the specification mentioned above... But be careful... Don't just copy my code and submit to your lecturer... If u do so, you'll be ... Believe me... Here we go...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Here's something else to play around with (needs testing, error handling etc)
sam mukhtar
Greenhorn

Joined: Mar 21, 2004
Posts: 12
koko thanks bro.. did you do this yourself or is it from the internet, the thing that i don't get is the "temp" can you explain how that works? thanks again bro
michael i'm sorry bro i really didn't understand your bit: how can i use it in the program or where
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by sam mukhtar:
koko thanks bro.. did you do this yourself or is it from the internet,

Oh! sam, r u insulting me?
Just kidding... I don't think you can find it on the internet, which suits exactly to the specification that you provided here... I did it myself... It took about 10 mins for me to finish it(Not mean to show off).

the thing that i don't get is the "temp" can you explain how that works? thanks again bro

temp is the temporary place to store the tax value calculated by the specification you provided... And finally I just check the age and return the value as appropriate...
While I was writing this program, I thought about my university life, when my lecturer gave me such assignments. I was really depressed, when I got stuck like you...
Enjoy my program... But I hope you know where in my code to change and submit to your lecturer...
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632

michael i'm sorry bro i really didn't understand your bit: how can i use it in the program or where

It is the program. Run it, test it.
There are always many ways to solve a problem. A switch statement is one
way to solve your current problem, my post is another way.
If it works, try to find out how it works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: urgent help needed for assignment