Question: the code; #include #include / / For rounding / / Function to calculate Adjusted Gross Income ( AGI ) int CalcAGI ( int wages, int

the code; #include
#include // For rounding
// Function to calculate Adjusted Gross Income (AGI)
int CalcAGI(int wages, int interest, int unemployment){
return wages + interest + unemployment;
}
// Function to get deduction based on status
int GetDeduction(int status){
switch (status){
case 0: return 6000;
case 1: return 12000;
case 2: return 24000;
default:
printf("Error: Must input status 0(dependent),1(single), or 2(married).
");
exit(1);
}
}
// Function to calculate taxable income
int CalcTaxable(int AGI, int deduction){
int taxable = AGI - deduction;
if (taxable <0){
taxable =0;
}
return taxable;
}
// Function to calculate federal tax based on status and taxable income
int CalcTax(int status, int taxable){
double federalTax;
if (status ==0|| status ==1){// Dependent or single filers
if (taxable <=10000){
federalTax = taxable *0.1;
} else if (taxable <=40000){
federalTax =1000+(taxable -10000)*0.12;
} else if (taxable <=85000){
federalTax =4600+(taxable -40000)*0.22;
} else {
federalTax =14500+(taxable -85000)*0.24;
}
} else if (status ==2){// Married filers
if (taxable <=20000){
federalTax = taxable *0.1;
} else if (taxable <=80000){
federalTax =2000+(taxable -20000)*0.12;
} else {
federalTax =9200+(taxable -80000)*0.22;
}
} else {
printf("Error: Invalid status for tax calculation.
");
exit(1);
}
return (int) round(federalTax);
}
// Function to calculate tax due or refund
int CalcTaxDue(int federalTax, int withheld){
int taxDue = federalTax - withheld;
if (taxDue >=0){
printf("Tax Owed: $%d
", taxDue);
} else {
printf("Tax Refund: $%d
",-taxDue);
}
return taxDue;
}
int main(){
int wages, interest, unemployment, status, withheld;
// Step 1: Input
printf("Please enter wages, taxable interest, and unemployment compensation: ");
scanf("%d %d %d", &wages, &interest, &unemployment);
printf("Please enter status (0 dependent, 1 single, 2 married): ");
scanf("%d", &status);
if (status !=0 && status !=1 && status !=2){
printf("Error: Must input status 0(dependent),1(single), or 2(married).
");
return 1;
}
printf("Please enter taxes withheld: ");
scanf("%d", &withheld);
if (withheld <0){
printf("Error: taxes withheld cannot be less than 0.
");
return 1;
}
// Step 2: Calculate AGI and display
int AGI = CalcAGI(wages, interest, unemployment);
printf("AGI: $%d
", AGI);
// Step 3: Calculate deduction and display
int deduction = GetDeduction(status);
printf("Deduction: $%d
", deduction);
// Step 4: Calculate taxable income and display
int taxableIncome = CalcTaxable(AGI, deduction);
printf("Taxable Income: $%d
", taxableIncome);
// Step 5: Calculate federal tax and display
int federalTax = CalcTax(status, taxableIncome);
printf("Federal Tax: $%d
", federalTax);
// Step 6: Calculate tax due or refund and display
int taxDueOrRefund = CalcTaxDue(federalTax, withheld);
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!