In: Computer Science
Write a program that does the following in order:
1. Asks the user to enter a name
2. Asks the user to enter a number “gross income”
3. Asks the user to enter a number “state tax rate”
4. Calculates the “Federal Tax”, “FICA tax” and “State tax”
5. Calculates the “estimated tax” and round the value to 2 decimal places
6. Prints values for “name”, “gross income” and “estimated tax”
The program should contain three additional variables to store the Federal tax, FICA tax, State tax, gross income, and estimated tax.
Federal Tax = gross income * 9.45%
FICA Tax = gross income * 7.65%
State Tax = gross income * your state tax percent
Estimated Tax = Federal tax + FICA tax + State tax
NOTE: Percentages must be converted to decimal values, for example:
15.9%=15.9*0.01=0.159
An example of the program’s input and output is shown below:
Enter your name: Belinda Patton
Enter your gross income: 53398.12
Enter your state income tax rate: 4.27
Tony Johnbull estimated tax is $11411.08 based on a gross income of $53398.12
#include <stdio.h>
#include<string.h>
int main()
{
char name[200];
float gross,state,federal_tax,fdia_tax,state_tax,Estimated_tax;
printf("Enter your name: ");
gets(name);
printf("Enter your gross income: ");
scanf("%f",&gross);
printf("Enter your state income tax rate: ");
scanf("%f",&state);
federal_tax=gross*(9.45*0.01);
fdia_tax=gross*(7.65*0.01);
state_tax=gross*(state*0.01);
Estimated_tax=federal_tax+fdia_tax+state_tax;
printf("%s estimated tax is $%.2f based on a gross income of $%.2f",name,Estimated_tax,gross);
return 0;
}
The above code is the program written in C which asks the user to enter the name and then enter the float values of gross income and the float values of state income tax rate and the according to the given values we calculate the values federal_tax,fdia_tax,state_tax and the by adding them we calculate the Estimated_tax and the display the result as required in the program output.
SCREENSHOT OF THE OUTPUT :
Here is the output screenshot of the given program and the photo is pasted aabove.