Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Can someone help me with my prog?

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Can someone help me with my prog?

    Hi everyone, i just started using java as i take the module in university and i have no programming experiance thefore i need a bit help with my first project.

    this is the question ((( A method that, given a child's income, returns the tax payable on that income. )))

    income in range of £ tax rate

    0 - 100 0%
    101-150 10%
    151-200 20%
    201-300 40%
    301-400 60%

    example of what i have to is the first 100 gets 0 taxed and the 50 gets taxed at %10 for example if the user enters 150 the first 100 wont get taxed but the 50 will get taxed and i dont know how to get java to know what user has entered and minus it by the amount that wont get taxed ...


    this is what i got so far please help >>>>>


    // to Scan users input

    import java.util.Scanner;

    import java.io.*;

    public class taxCalculator {

    // The main
    public static void main(String[] args)

    {
    // These are fixed tax rates
    //Constants

    final double Tax_Rate = 0.0; // first 100 will be taxed at 0%
    final double Tax_Rate1 = 0.10;
    final double Tax_Rate2 = 0.20;
    final double Tax_Rate3 = 0.40;
    final double Tax_Rate4 = 0.60;
    // final double Tax_Rate5 = 0.120;
    //final int Tax_Tax = 100;

    // Calling the scanner in to the program

    Scanner scan = new Scanner(System.in);

    // These are the variables takes from user input

    double userIncome; // input from the user
    double incomeTax; // outputs to the user their calculated income tax

    // Request inputs from the user

    System.out.println("Enter childs income:");

    userIncome = scan.nextDouble();

    // calculating the income tax of the amount
    // included if and else statement

    if ( userIncome >= 0 && userIncome <= 100)
    {

    incomeTax = userIncome * Tax_Rate;

    System.out.println("There is no taxable amount on this income" + incomeTax); // prints statement

    }

    else if ( userIncome >= 101 && userIncome <= 150){

    incomeTax = userIncome * Tax_Rate1;

    System.out.println(" the income tax of this child is £ " + incomeTax );

    }

    else if ( userIncome >=151 && userIncome <= 200 )

    {


    incomeTax = userIncome * Tax_Rate2;

    System.out.println("the income tax of this child is " + incomeTax );


    }

    else if ( userIncome >= 201 && userIncome <= 300)

    {


    incomeTax = userIncome * Tax_Rate3;

    System.out.println("The income tax of this child is " + incomeTax);

    }

    else if ( userIncome >= 301 && userIncome <= 400 )

    {

    incomeTax = userIncome * Tax_Rate4;

    System.out.println("The income tax of this child is " + incomeTax );

    Math.round(incomeTax); // math round is used to round up the number of the income tax to an hole number

    }
    }
    }




    my code takes an the user input e.g if theuser enters 100 it wont get taxed but if the user enters 150 it will tax all the 150 i need to tax the 50 only how do i do this ?


    thank you in advance for your helps and i don't expect anyone to do my work for me i just need some tips to know where am going wrong.

    using ECLIPSE


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Can someone help me with my prog?

    Why in the name of all good are you spamming the forum with multiple copies of the same post? I'm no moderator, but in many forums this can get you banned. I suggest you delete the copies and keep *one* post.

  3. The Following User Says Thank You to curmudgeon For This Useful Post:

    jps (November 4th, 2012)

  4. #3
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Can someone help me with my prog?

    Please don't post the same question in multiple forums on this site. The others will be deleted.

Similar Threads

  1. help java prog
    By darking123 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 23rd, 2012, 05:24 PM
  2. help java prog
    By darking123 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 18th, 2012, 10:38 PM
  3. Help with prog please.
    By Flantoons in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 15th, 2011, 05:10 AM
  4. need help prog skipping method
    By Pulse_Irl in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 11th, 2010, 08:57 AM