Skip to content

Instantly share code, notes, and snippets.

@GrandNewbien
Last active January 29, 2018 01:39
Show Gist options
  • Save GrandNewbien/3e4e27ba8a3b667b1fd0f7138c478735 to your computer and use it in GitHub Desktop.
Save GrandNewbien/3e4e27ba8a3b667b1fd0f7138c478735 to your computer and use it in GitHub Desktop.
double taxer(){
if (this.status.equals("single")){
int cutoff10 = 8350;
int cutoff15 = 33950;
int cutoff30 = 82250;
}
else if (this.status.equals("married")){
int cutoff10 = 16700;
int cutoff15 = 67900;
int cutoff30 = 137050;
}
else if (this.status.equals("household")){
int cutoff10 = 11950;
int cutoff15 = 45500;
int cutoff30 = 117450;
}
{
double tax = this.income;
if (tax >=0 && tax <cutoff10)
{
double tax_final = this.income *0.10;
return tax_final
}
else if (tax>=cutoff10 && tax <cutoff15)
{
double part1 = cutoff10 * 0.10;
double part2 = (this.income - cutoff10) * 0.15;
double tax_final = part1 + part2;
return tax_final
}
else if (tax>=cutoff 15 && tax<cutoff30)
{
double part1 = cutoff10 * 0.10;
double part2 = (cutoff15 - cutoff10) * 0.15;
double part3 = (this.income - cutoff15) * 0.3;
double tax_final = part1 + part2 + part3;
return tax_final;
}
else if (tax>=cutoff30)
{
double part1 = cutoff10 * 0.10;
double part2 = (cutoff15 - cutoff10) * 0.15;
double part3 = (cutoff30 - cutoff15) * 0.3;
double part4 = (this.income - cutoff30) * 0.3
double tax_final = part1 + part2 + part3 + part4;
return tax_final;
}
}
return 0; // must have return statement.. can't be empty string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment