Article View: aus.computers.java
Article #1169Re: Beginniner needs help, please
From: James
Date: Mon, 28 Jun 1999 00:00
Date: Mon, 28 Jun 1999 00:00
101 lines
3542 bytes
3542 bytes
mrbafner wrote:
> i have written this program, to try and work out the tax taken from their
> gross salaries.
>
> I run it and 2 extra lines appear (blank), if you put in a interger number,
> the net wage has these 2 numbers taken from it NOT THE TAX.
>
> how can I work it out so the tax is taken from the net amount. It has to be
> 30% tax, with a 10,000 tax free threshhold based on the amount that has been
> entered. PLEASE HELP I AT MY TETHER
>
> THANKS
> MrBafner
>
> =====================================================
>
> import java.io.*;
> class PaulsMoney {
> public static void main (String[] args)
> throws IOException {
>
> // create a text input stream
> BufferedReader stdin = new BufferedReader
> (new InputStreamReader (System.in));
> String initString;
> int initialSalary;
>
> System.out.println ("TAX CALCULATION PROGRAM");
> System.out.print ("Enter the employee's salary: ");
>
> initString = stdin.readLine();
> initialSalary = Integer.parseInt (initString);
>
// For starters you are declaring an int with out a variable name
// secondly you should deduct the tax free threashold first and the variable
should
// be a float or double
// eg float taxPaid = (initialSalary - 10000) * .3
// that is very simplistic though.
>
> int = initialSalary * .30;
>
> if (initialSalary < 30000) {
> System.out.print ("Tax Paid: ");
> System.out.println (initialSalary * .30);
> }
>
> else; {
> System.out.print ("Salary: ");
> System.out.println (initialSalary);
> }
> }
> }
>
> ===================================================================
Your description of the program seems to be different from the code that you
have
written - either that or I've had too many late nights.
If you entered in the Gross wages and allowed the program to deduct the tax free
threashold
and then spit out the amout it would be on these lines:
import java.io.*;
public class PaulsMoney
{
public int taxFreeThreshold;
public PaulsMoney() { taxFreeThreshold = 1000;}
public static void main (String[] args) throws IOException {
PaulsMoney p = new PaulsMoney();
BufferedReader stdin = new BufferedReader(new InputStreamReader
(System.in));
String input;
int grossSalary;
input = stdin.readLine();
grossSalary = Integer.parseInt(input);
System.out.print("Tax paid: ");
float taxPaid = (float)(grossSalary - p.taxFreeThreshold) * 0.3;
if taxPaid > 0
System.out.println("$0.00");
else
System.out.println(taxPaid);
}
}
It doesn do what your code seemed to be doing but it does do what you have
asked.
Hope it was of some help.
Technical Details
Message-ID:
<37763715.2F9E67D8@geocities.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<Ourc3.164$wE1.14566@nsw.nnrp.telstra.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,386b2c114babcc7c X-Google-Attributes: gid10d6db,public From: James <jamesrobson@geocities.com> Subject: Re: Beginniner needs help, please Date: 1999/06/28 Message-ID: <37763715.2F9E67D8@geocities.com> X-Deja-AN: 494433752 Content-Transfer-Encoding: 7bit References: <Ourc3.164$wE1.14566@nsw.nnrp.telstra.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.usyd.edu.au X-Trace: metro.ucc.usyd.edu.au 930494463 7219 10.0.24.178 (27 Jun 1999 14:41:03 GMT) Organization: The University of Sydney, Australia Mime-Version: 1.0 NNTP-Posting-Date: 27 Jun 1999 14:41:03 GMT Newsgroups: aus.computers.java