Java Code running problem
This is the code
Code:
import java.util.Scanner;
public class Taxes
{
static double taxes;
public static void main(String[] args)
{
// Prompting
System.out.println("Enter maritial status (1=single, 2=married)");
Scanner scanner= new Scanner(System.in);
int marital=scanner.nextInt();
System.out.println("Enter taxable income: ");
Scanner scanner1 = new Scanner(System.in);
double income=scanner.nextDouble();
if(marital ==1);
if(marital ==2);
System.out.println("Your Federal Tax = $" + single(income));
}
public static double single(double s)
{
//finding out tax for single
if (s > 0 && s<=27050)
taxes= .15*(s-0);
if (s > 27050 && s<=65550)
taxes= 4057.50 + 0.275*(s-27050);
if (s > 65550 && s<=136750)
taxes= 14645.00 + 0.305*(s-65550);
if (s > 136750 && s<=297350)
taxes= 36361.00 + .355*(s-136750);
if (s > 297350)
taxes= 93374.00 + .391*(s-297350);
return taxes;
}
public static double married(double m)
{
//finding out tax for double
if (m > 0 && m <= 45200)
taxes= .15*(m-0);
if (m > 45200 && m <= 109250)
taxes= 6780.00 + .275*(m-45200);
if (m > 109250 && m <= 166500)
taxes= 24393.75 + .305*(m-109250);
if (m > 166500 && m <= 297350)
taxes= 41855.00 + .355*(m-166500);
if (m> 297350)
taxes= 88306.00 + .391*(m-297350);
return taxes;
}
}
when i run this code, i need to run it as for single and married when it is prompted. even though i have the married if statements, when input for married it still refers to the top formulas. when i refer to 1 for single the formulas work fine and output is correct, the output for both the single and the married are the same even though the married is supposed to refer to the below portion of if statements and not the top. how can i change this i am stuck here and my code will run perfectly.
thank you