This is my homework for a Java class. I get a perfect score followed by a query as to why I didn't use a void method. The answer is I don't understand the difference. Can someone illustrate for me how it would look. I need a better grasp of this.
Thank you.
public class taxTable {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Taxable Single Married Married Head of ");
System.out.println("Income Joint Separate Household");
int status = 0;
for (double income = 50000; income <= 60000; income = income + 50){
System.out.print(income + " ");
computeTaxStat(status, income);
System.out.println();
}
}
public static double printComputeTax(double income,
int r1, int r2, int r3) {
double tax = 0;
if (income <= r1)
tax = income * 0.10;
else if (income <= r2)
tax = r1 * 0.10 + (income - r1) * 0.15;
else if (income <= r3)
tax = r1 * 0.10 + (r2 - r1) * 0.15 + (income - r2) * 0.25;
System.out.print(tax+ " ");
return 0;
}
public static double computeTaxStat(int status, double income) {
for(status =0; status<= 3; status++) {
if(status == 0)
printComputeTax(income, 8350, 33950, 82250);
else if (status == 1)
printComputeTax(income, 16700, 67900, 137050);
else if (status == 2)
printComputeTax(income, 8350, 33950, 68525);
else if (status == 3)
printComputeTax(income, 11950, 45500, 117450);
}
return 0;
}
}