Results 1 to 12 of 12
  1. #1
    sabarooni's Avatar
    sabarooni is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Red face Tax calculation program help!!

    Hi, I am trying to create a program which calculates tax for x amount of years, given annual salary (S), annual increase (I), and number of years (X).

    the number of years must be between 1 and 10, and is input by the user. The program then displays the gross tax and net tax and salary for the year for x number of years.

    Could anyone please help me out on what I should use in the program for the number of years? I was thinking about using a for loop, but I'm not sure how I would implement it.

    please help!!

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: Tax calculation program help!!

    What do you mean by "what I should use in the program for the number of years"? Sounds like an int to me.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    sabarooni's Avatar
    sabarooni is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default Re: Tax calculation program help!!

    Quote Originally Posted by KevinWorkman View Post
    What do you mean by "what I should use in the program for the number of years"? Sounds like an int to me.
    ye I am using an int, and yea I don't think I explained it very well lol

    say, for example the number of years input is 3, basic salary is £15,000, annual increase is 10%

    then the output needs to be (for gross salary):

    year1: 15, 000
    year2: 16,500
    year3: 18,150

    I can do all the calculations etc, but I don't know how to make it display the desired number of years. I also need to display the tax for each year, but I think it will be the same method as displaying the gross salary.

    Any tips you can give?

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: Tax calculation program help!!

    Well, a for loop sounds reasonable to me. What happened when you tried that?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    sabarooni's Avatar
    sabarooni is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default Re: Tax calculation program help!!

    Quote Originally Posted by KevinWorkman View Post
    Well, a for loop sounds reasonable to me. What happened when you tried that?
    I haven't yet tried to put the for loop in because I don't fully understand how it works but I will try it now and reply with results, thanks for the tip!

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: Tax calculation program help!!

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    sabarooni's Avatar
    sabarooni is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default Re: Tax calculation program help!!

    Thanks alot!

    I used a for statement, and now if I input the year and basic salary, it prints out the gross tax for each of the years.
    Now I just need to be able to increment the annual percentage increase each year, hopefully shouldn't be too hard!

  8. #8
    sabarooni's Avatar
    sabarooni is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default Re: Tax calculation program help!!

    Hi I can't seem to implement the annual increase, I can only get as far as the program printing out the same starting salary for each year, can anyone help?
    thanks in advance!

  9. #9
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: Tax calculation program help!!

    Quote Originally Posted by sabarooni View Post
    Hi I can't seem to implement the annual increase, I can only get as far as the program printing out the same starting salary for each year, can anyone help?
    thanks in advance!
    If you want help, you should provide an SSCCE that demonstrates what you have so far. Otherwise we're just guessing.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #10
    sabarooni's Avatar
    sabarooni is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default Re: Tax calculation program help!!

    Java Code:
    import java.util.Scanner ;
    
    class Salary
    {
    	static Scanner input = new Scanner (System.in) ;
    	
    	public static void main (String args [])
    	{
    	
    ////////////////////////////////////////////////////////////
    //DECLERATIONS
    ////////////////////////////////////////////////////////////
    
    		double basicsalary, annualincrease ;
    		int years ;
    		
    ////////////////////////////////////////////////////////////
    //INPUT
    ////////////////////////////////////////////////////////////
    		
    		System.out.print("Enter annual salary before tax: ") ;
    		basicsalary = input.nextDouble () ;
    		System.out.print("Enter annual percentage increase in salary: ") ;
    		annualincrease = input.nextDouble () ;
    		System.out.print("Enter number of years to be calculated: ") ;
    		years = input.nextInt () ;
    		
    
    ////////////////////////////////////////////////////////////
    //INSTANTIATE A COPY OF SALARYMATHS
    ////////////////////////////////////////////////////////////
    
    		Salarymaths sm = new Salarymaths () ;
    		
    ////////////////////////////////////////////////////////////
    //ANNUAL GROSS SALARY OUTPUT
    ////////////////////////////////////////////////////////////
    
    		System.out.println () ;
    		System.out.println ("Gross Salary before tax for "+years+" years: ") ;
    		
    		for (int g=1 ; g<=years ; g++)
    		{
    			System.out.print ("Year "+g+": ") ;
    			System.out.println (basicsalary) ;
    		}
    
    			
    	}
    }
    This is pretty much what I have so far, an example would be:

    basicsalary: 15,000
    annualincrease: 20
    years: 5

    This prints out:

    Year1 15000
    Year2 15000
    Year3 15000
    Year4 15000
    Year5 15000

    I want the salary to increase by the inputted percentage (in this case, 20) each year, and I have no idea how to do it, I am guessing I should use a sequence somehow but I have no idea where to start!

  11. #11
    sabarooni's Avatar
    sabarooni is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default Re: Tax calculation program help!!

    Quote Originally Posted by KevinWorkman View Post
    If you want help, you should provide an SSCCE that demonstrates what you have so far. Otherwise we're just guessing.
    is that what you meant by SSCCE? :)

  12. #12
    sabarooni's Avatar
    sabarooni is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default Re: Tax calculation program help!!

    I figured it out! thanks for the help Kevin!

Similar Threads

  1. Moretgage Calculation
    By rsmithjr316 in forum New To Java
    Replies: 3
    Last Post: 01-17-2011, 03:32 AM
  2. Problem with calculation
    By ibrafiqb in forum New To Java
    Replies: 3
    Last Post: 11-24-2010, 05:02 PM
  3. Help with the calculation of a variable.
    By rarschach in forum New To Java
    Replies: 14
    Last Post: 01-24-2010, 02:50 PM
  4. Two problem for my rssi calculation program
    By iamchoilan in forum Java 2D
    Replies: 12
    Last Post: 04-27-2008, 07:56 PM
  5. Two problem for my rssi calculation program
    By iamchoilan in forum Advanced Java
    Replies: 3
    Last Post: 04-25-2008, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •