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