One of the big ideas we'll encounter again and again this term is that we can take the value returned by one function and use it as an argument to another function. Let's try it with an example.
Assume that a person's income tax is based on their annual income, their tax bracket (a percentage), and the number of dependents they claim (a person may claim 0 or more dependents). The amount of income tax owed is calculated by multiplying a person's income by their tax bracket, then deducting $1000 for every dependent claimed. For example, if a taxpayer is in the 25% tax bracket and they claim 3 dependents, that person's income tax will be calculated by multiplying their annual income by 0.25, then subtracting $3000. If the calculation results in a negative number, a value of 0 should be produced.
A person's tax bracket is based on that person's annual income and marital status (either single or married). Here are the tax brackets for a single person:
| Income | Bracket | |
|---|---|---|
| $0 - $14,999 | 10% | |
| $15,000 - $49,999 | 20% | |
| $50,000 - $99,999 | 25% | |
| $100,000 or more | 35% |
and here are the brackets for a married person:
| Income | Bracket | |
|---|---|---|
| $0 - $31,999 | 10% | |
| $32,000 - $129,999 | 20% | |
| $130,000 - $224,999 | 25% | |
| $225,000 or more | 35% |
Do the following:
Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
public class TEST{
public static double bracket(double income,boolean status)
{
if(status==true)
{
if(income<15000)
{
return 0.1;
}
else if(income<50000)
{
return 0.2;
}
else if(income<100000)
{
return 0.25;
}
else
{
return 0.35;
}
}
else
{
if(income<32000)
{
return 0.1;
}
else if(income<130000)
{
return 0.2;
}
else if(income<225000)
{
return 0.25;
}
else
{
return 0.35;
}
}
}
public static double tax(double income,boolean status,int
num)
{
double p=bracket(income,status);
double t=p*income-num*1000;
if(t<0)
return 0;
return t;
}
public static void main(String []args){
System.out.println("Tax is "+tax(50000,false,5));
}
}

Kindly revert for any queries
Thanks.
One of the big ideas we'll encounter again and again this term is that we can...