C PROGRAMMING ONLY: This program has to be unique and original, not plagarized.
ID: 3751265 • Letter: C
Question
C PROGRAMMING ONLY:
This program has to be unique and original, not plagarized.
This should be made using only selection, assignments, variables, iteration, and arrays. Nothing more advanced.
Please do not use or any other abnormalalities for a intro level C student such as <conio.h>
This program has to be made in C and be compiled in gcc
Project Overview: In this project, you will use your knowledge of selection and iteration to write a program to help tax payers to figure out their 2018 estimated taxes. The program will ask the user for the filing status and estimated taxable income, and then compute and print the estimated taxes using the tax rate schedules as shown below. (The line 3 mentioned in the tax rate schedules below is the estimated taxable income.)
The program will first prompt the user to enter an integer (1 through 5) that represents their filing status as shown below. If the user enters an invalid filing status, the program will print out an error message and ask for the filing status again. The program will keep asking the same question until the user enters a valid filing status.
1. Single
2. Married filing jointly
3. Married filing separately
4. Head of household
5. Qualifying widow(er)
The program will then prompt for their estimated taxable income (a real number). If the user enters a negative value, the program will print out an error message and change the income to be 0 (zero).
Based on the filing status and the taxable income, the program will compute and print the estimated tax. Please make sure that each output value be properly labeled and formatted. Otherwise you may not receive credit. For the tax amount in this project, you need to limit it two decimal places.
The program shall handle multiple tax payers. Once the program finishes with computing the tax for the first tax payer, it will ask for filing status and taxable income of the second tax payer. The process continues until the user enters 0 as the filing status. At that point, the program will say goodbye and terminate. A sample execution of the program is shown at the end of this document, with the program prompts/output in red and the user input in blue.
You need to test your program with every filing status and every tax bracket.
2018 Tax Rate Schedules CAUTION Don't use these Tax Rate Schedules to figure your 2017 taxes. Use them only to figure your 2018 estimated taxes Schedule X-Use if your 2018 filing status is Single Schedule Z-Use if your 2018 filing status is Head of household If line 3 is: The tax is: If line 3 is The tax is: of the amount of the But not But not Over- erOver $9,525 38,700 SO 9,525 38,700 82,500 57,500 200.000 500,000 10% 952.50 + 12% 82.500 4,453.50+22% 157,500 14,089.50+24% 200,000 32,089.50+32% 500.000 45,689.50+35% 150,689.50 + 37% $O 13,600 51,800 82,500 57,500157,500 SO 9,525 38,700 82,500 $13,600 10% 51,800 $1,360.00 + 12% 82.500 5,944.00 +22% 157,500 12,698.00+24% 200,000 30,698.00+32% 500,000 44,298.00 + 35% 149,298.00 + 37% So 13,600 51,800 157,500 200,000 500,000 200,000 200,000 500,000500,000 Schedule Y-1-Use if your 2018 filing status is Married filing jointly or Qualifying widow(er) Schedule Y-2-Use if your 2018 filing status is Married filing separately The tax is: If line 3 is The tax is: of the of the But not But not overOver SO 9.050 77,400 $19,050 10% 77,400 $1,905.00 + 12% 8,907.00 + 22% 315,000 28,179.00 +24% 400,000 64,179.00 + 32% 600.000 91,379.00 + 35% 161,379.00 + 37% S0 9.525 38,700 82.500 $9,525 38,700 82.500 157,500 200,000 300.000 SO 10% $952.50+12% 4,453.50+22% 14,089.50+24% 32,089.50+32% 45,689.50 + 35% 80,689.50 + 37% sO 9,050 77,400 165,000 15,000 157,5002 00,000200,000 600,000 300,000 165,000 315,000 400,000 600,000 38,700 82,500 157,500 200,000 300,000 ..Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
// Function to calculate tax for Single category
void calculateTaxSingle(float income)
{
// To store tax percentage and tax amount
float percent, tax;
// Checks if income is between 0 and 9525 inclusive
if(income <= 9525)
{
// Stores percentage of tax
percent = 10;
// Calculates tax
tax = income * 0.10;
}// End of if condition
// Checks if income is between 9526 and 38700 inclusive
else if(income <= 38700)
{
// Stores percentage of tax
percent = 12;
// Calculates tax
tax = 9525.50 + ((income - 9525) * 0.12);
}// End of else if condition
// Checks if income is between 38701 and 82500 inclusive
else if(income <= 82500)
{
// Stores percentage of tax
percent = 22;
// Calculates tax
tax = 4453.50 + ((income - 38700) * 0.22);
}// End of else if condition
// Checks if income is between 82501 and 157500 inclusive
else if(income <= 157500)
{
// Stores percentage of tax
percent = 24;
// Calculates tax
tax = 14089.50 + ((income - 82500) * 0.24);
}// End of else if condition
// Checks if income is between 157501 and 200000 inclusive
else if(income <= 200000)
{
// Stores percentage of tax
percent = 32;
// Calculates tax
tax = 32089.50 + ((income - 157500) * 0.32);
}// End of else if condition
// Checks if income is between 200001 and 500000 inclusive
else if(income <= 500000)
{
// Stores percentage of tax
percent = 35;
// Calculates tax
tax = 45689.50 + ((income - 200000) * 0.35);
}// End of else if condition
// Otherwise more than 500000
else
{
// Stores percentage of tax
percent = 37;
// Calculates tax
tax = 150689.50 + ((income - 500000) * 0.37);
}// End of else
// Displays tax information
printf(" Income: $%.2f Percent: %.2f Tax: $%.2f Amount to be paid: $%.2f", income, percent, tax, (income + tax));
}// End of function
// Function to calculate tax for MarriedJointly and Qualifying widow(er) category
void calculateTaxMarriedJointly(float income)
{
// To store tax percentage and tax amount
float percent, tax;
// Checks if income is between 0 and 19050 inclusive
if(income <= 19050)
{
// Stores percentage of tax
percent = 10;
// Calculates tax
tax = income * 0.10;
}// End of if condition
// Checks if income is between 19051 and 77400 inclusive
else if(income <= 77400)
{
// Stores percentage of tax
percent = 12;
// Calculates tax
tax = 1905.00 + ((income - 19050) * 0.12);
}// End of else if condition
// Checks if income is between 77401 and 165000 inclusive
else if(income <= 165000)
{
// Stores percentage of tax
percent = 22;
// Calculates tax
tax = 8907.00 + ((income - 77400) * 0.22);
}// End of else if condition
// Checks if income is between 165001 and 315000 inclusive
else if(income <= 315000)
{
// Stores percentage of tax
percent = 24;
// Calculates tax
tax = 28179.00 + ((income - 165000) * 0.24);
}// End of else if condition
// Checks if income is between 315001 and 400000 inclusive
else if(income <= 400000)
{
// Stores percentage of tax
percent = 32;
// Calculates tax
tax = 64179.00 + ((income - 315000) * 0.32);
}// End of else if condition
// Checks if income is between 400001 and 600000 inclusive
else if(income <= 600000)
{
// Stores percentage of tax
percent = 35;
// Calculates tax
tax = 91679.00 + ((income - 400000) * 0.35);
}// End of else if condition
// Otherwise more than 600000
else
{
// Stores percentage of tax
percent = 37;
// Calculates tax
tax = 161379.00 + ((income - 600000) * 0.37);
}// End of else
// Displays tax information
printf(" Income: $%.2f Percent: %.2f Tax: $%.2f Amount to be paid: $%.2f", income, percent, tax, (income + tax));
}// End of function
// Function to calculate tax for MarriedSeparately category
void calculateTaxMarriedSeparately(float income)
{
// To store tax percentage and tax amount
float percent, tax;
// Checks if income is between 0 and 9525 inclusive
if(income <= 9525)
{
// Stores percentage of tax
percent = 10;
// Calculates tax
tax = income * 0.10;
}// End of if condition
// Checks if income is between 9526 and 38700 inclusive
else if(income <= 38700)
{
// Stores percentage of tax
percent = 12;
// Calculates tax
tax = 9525.50 + ((income - 9525) * 0.12);
}// End of else if condition
// Checks if income is between 38701 and 82500 inclusive
else if(income <= 82500)
{
// Stores percentage of tax
percent = 22;
// Calculates tax
tax = 4453.50 + ((income - 38700) * 0.22);
}// End of else if condition
// Checks if income is between 82501 and 157500 inclusive
else if(income <= 157500)
{
// Stores percentage of tax
percent = 24;
// Calculates tax
tax = 14089.50 + ((income - 82500) * 0.24);
}// End of else if condition
// Checks if income is between 157501 and 200000 inclusive
else if(income <= 200000)
{
// Stores percentage of tax
percent = 32;
// Calculates tax
tax = 32089.50 + ((income - 157500) * 0.32);
}// End of else if condition
// Checks if income is between 200001 and 300000 inclusive
else if(income <= 300000)
{
// Stores percentage of tax
percent = 35;
// Calculates tax
tax = 45689.50 + ((income - 200000) * 0.35);
}// End of else if condition
// Otherwise more than 300000
else
{
// Stores percentage of tax
percent = 37;
// Calculates tax
tax = 80689.50 + ((income - 300000) * 0.37);
}// End of else
// Displays tax information
printf(" Income: $%.2f Percent: %.2f Tax: $%.2f Amount to be paid: $%.2f", income, percent, tax, (income + tax));
}// End of function
// Function to calculate tax for Household category
void calculateTaxHousehold(float income)
{
// To store tax percentage and tax amount
float percent, tax;
// Checks if income is between 0 and 13600 inclusive
if(income <= 13600)
{
// Stores percentage of tax
percent = 10;
// Calculates tax
tax = income * 0.10;
}// End of if condition
// Checks if income is between 13601 and 51800 inclusive
else if(income <= 51800)
{
// Stores percentage of tax
percent = 12;
// Calculates tax
tax = 1360.00 + ((income - 13600) * 0.12);
}// End of else if condition
// Checks if income is between 51801 and 82500 inclusive
else if(income <= 82500)
{
// Stores percentage of tax
percent = 22;
// Calculates tax
tax = 5944.00 + ((income - 51800) * 0.22);
}// End of else if condition
// Checks if income is between 82501 and 157500 inclusive
else if(income <= 157500)
{
// Stores percentage of tax
percent = 24;
// Calculates tax
tax = 12698.00 + ((income - 82500) * 0.24);
}// End of else if condition
// Checks if income is between 157501 and 200000 inclusive
else if(income <= 200000)
{
// Stores percentage of tax
percent = 32;
// Calculates tax
tax = 30689.00 + ((income - 157500) * 0.32);
}// End of else if condition
// Checks if income is between 200001 and 500000 inclusive
else if(income <= 500000)
{
// Stores percentage of tax
percent = 35;
// Calculates tax
tax = 44298.00 + ((income - 200000) * 0.35);
}// End of else if condition
// Otherwise more than 500000
else
{
// Stores percentage of tax
percent = 37;
// Calculates tax
tax = 149298.00 + ((income - 500000) * 0.37);
}// End of else
// Displays tax information
printf(" Income: $%.2f Percent: %.2f Tax: $%.2f Amount to be paid: $%.2f", income, percent, tax, (income + tax));
}// End of function
// Function to display menu, accept user choice and return user choice
int menu()
{
// To store user choice
int ch;
// Displays menu
printf(" 1. Single.");
printf(" 2. Married filing jointly.");
printf(" 3. Married filing separately.");
printf(" 4. Head of household.");
printf(" 5. Qualifying widow(er).");
// Accepts user choice
printf(" Enter your filling status: ");
scanf("%d", &ch);
// Returns user choice
return ch;
}// End of function
// main function definition
int main()
{
// To store income
float income;
// Loops till user choice is not 0
do
{
// Loops till valid income entered by the user
do
{
// Accepts income from the user
printf(" Enter your income: ");
scanf("%f", &income);
// Checks if income is negative then display error message
if(income < 0)
printf(" Invalid income. Try again.");
// Otherwise valid income come out of the loop
else
break;
}while(1); // End of do - while loop
// Based on
// Calls the function to accept user choice
// Based on the return value of the function calls the appropriate function
switch(menu())
{
case 0:
printf(" Good Bye.");
exit(0);
case 1:
printf(" Filling category: Single");
calculateTaxSingle(income);
break;
case 2:
printf(" Filling category: Married Jointly");
calculateTaxMarriedJointly(income);
break;
case 3:
printf(" Filling category: Married Separately");
calculateTaxMarriedSeparately(income);
break;
case 4:
printf(" Filling category: Household");
calculateTaxHousehold(income);
break;
case 5:
printf(" Filling category: Qualifying widow(er)");
calculateTaxMarriedJointly(income);
break;
default:
printf(" Invalid choice. Try again.");
}// End of switch case
}while(1); // End of outer do - while loop
return 0;
}// End of main function
Sample Output:
Enter your income: 9200
1. Single.
2. Married filing jointly.
3. Married filing separately.
4. Head of household.
5. Qualifying widow(er).
Enter your filling status: 1
Filling category: Single
Income: $9200.00 Percent: 10.00 Tax: $920.00
Amount to be paid: $10120.00
Enter your income: 165900
1. Single.
2. Married filing jointly.
3. Married filing separately.
4. Head of household.
5. Qualifying widow(er).
Enter your filling status: 2
Filling category: Married Jointly
Income: $165900.00 Percent: 24.00 Tax: $28395.00
Amount to be paid: $194295.00
Enter your income: 200000
1. Single.
2. Married filing jointly.
3. Married filing separately.
4. Head of household.
5. Qualifying widow(er).
Enter your filling status: 3
Filling category: Married Separately
Income: $200000.00 Percent: 32.00 Tax: $45689.50
Amount to be paid: $245689.50
Enter your income: 300000
1. Single.
2. Married filing jointly.
3. Married filing separately.
4. Head of household.
5. Qualifying widow(er).
Enter your filling status: 4
Filling category: Household
Income: $300000.00 Percent: 35.00 Tax: $79298.00
Amount to be paid: $379298.00
Enter your income: 800000
1. Single.
2. Married filing jointly.
3. Married filing separately.
4. Head of household.
5. Qualifying widow(er).
Enter your filling status: 5
Filling category: Qualifying widow(er)
Income: $800000.00 Percent: 37.00 Tax: $235379.00
Amount to be paid: $1035379.00
Enter your income: -10
Invalid income.
Try again.
Enter your income: 500000
1. Single.
2. Married filing jointly.
3. Married filing separately.
4. Head of household.
5. Qualifying widow(er).
Enter your filling status: 7
Invalid choice.
Try again.
Enter your income: 0
1. Single.
2. Married filing jointly.
3. Married filing separately.
4. Head of household.
5. Qualifying widow(er).
Enter your filling status: 0
Good Bye.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.