Name: Anonymous 2008-10-12 12:38
/*TODO
* Have something actually call printData
*/
import java.util.Scanner;
public class IRS
{
public static void main(String[] args)
{
new IRS();
}
private Scanner in;
private int married;
private double income;
public IRS()
{
married = 1;
income = 0;
in = new Scanner(System.in);
}
public IRS(int m, double i)
{
married = m;
income = i;
in = new Scanner(System.in);
}
public boolean inputData()
{
boolean valid = false;
System.out.print("Enter marital status (1=single, 2=married): ");
married = in.nextInt();
if(married == 1 || married == 2)
{
valid = true;
}
System.out.print("Enter taxable income: ");
income = in.nextDouble();
if(income < 0)
{
valid = false;
}
return valid;
}
public double calcTax()
{
if(married == 1)
{
if(income <= 2750)
{
return income * 0.15;
}
else if(income <= 65550)
{
return (income - 27050) * 0.275 + 4057.5;
}
else if(income <= 136750)
{
return (income - 65550) * 0.305 + 14645;
}
else if(income <= 297350)
{
return (income - 136750) * 0.355 + 36361;
}
else
{
return (income - 297350) * 0.391 + 93374;
}
}
else
{
if(income <= 45200)
{
return income * 0.15;
}
else if(income <= 109250)
{
return (income - 45200) * 0.275 + 6780;
}
else if(income <= 166500)
{
return (income - 109250) * 0.305 + 24393.75;
}
else if(income <= 297350)
{
return (income - 166500) * 0.355 + 41855;
}
else
{
return (income - 297350) * 0.391 + 88306;
}
}
}
public void printData()
{
System.out.print("Your Federal tax= ");
System.out.printf("$%.2f", calcTax());
System.out.println();
}
}
//The goal: modify this program to actually take the user's input and call printData() after doing calculations
* Have something actually call printData
*/
import java.util.Scanner;
public class IRS
{
public static void main(String[] args)
{
new IRS();
}
private Scanner in;
private int married;
private double income;
public IRS()
{
married = 1;
income = 0;
in = new Scanner(System.in);
}
public IRS(int m, double i)
{
married = m;
income = i;
in = new Scanner(System.in);
}
public boolean inputData()
{
boolean valid = false;
System.out.print("Enter marital status (1=single, 2=married): ");
married = in.nextInt();
if(married == 1 || married == 2)
{
valid = true;
}
System.out.print("Enter taxable income: ");
income = in.nextDouble();
if(income < 0)
{
valid = false;
}
return valid;
}
public double calcTax()
{
if(married == 1)
{
if(income <= 2750)
{
return income * 0.15;
}
else if(income <= 65550)
{
return (income - 27050) * 0.275 + 4057.5;
}
else if(income <= 136750)
{
return (income - 65550) * 0.305 + 14645;
}
else if(income <= 297350)
{
return (income - 136750) * 0.355 + 36361;
}
else
{
return (income - 297350) * 0.391 + 93374;
}
}
else
{
if(income <= 45200)
{
return income * 0.15;
}
else if(income <= 109250)
{
return (income - 45200) * 0.275 + 6780;
}
else if(income <= 166500)
{
return (income - 109250) * 0.305 + 24393.75;
}
else if(income <= 297350)
{
return (income - 166500) * 0.355 + 41855;
}
else
{
return (income - 297350) * 0.391 + 88306;
}
}
}
public void printData()
{
System.out.print("Your Federal tax= ");
System.out.printf("$%.2f", calcTax());
System.out.println();
}
}
//The goal: modify this program to actually take the user's input and call printData() after doing calculations