In: Computer Science
Need this in C# and also the Pseudocode.
Program 4: In 1789, Benjamin Franklin is known to have written “Our new Constitution is now established, and has an appearance that promises permanency; but in this world nothing can be said to be certain, except death and taxes.” Our federal tax system is a “graduated” tax system which is broken into seven segments. Essentially, the more you make, the higher your tax rate. For 2018, you can find the tax brackets here. Your task is to design (pseudocode) and implement (source code) a program that asks the user for a salary and calculates the federal tax owed. Note, that only the money above a particular tax bracket gets taxed at the higher rate. For example, if someone makes $10,000 a year, the first $9525 gets taxed at 10%. The “excess” above that ($475) gets taxed at 12%. Note: work through at least three (3) examples of this by hand before designing the code. It will save you significant time.
Sample run 1:
Enter your salary to the nearest dollar: 2000
Total tax owed is: $200
Sample run 2:
Enter your salary to the nearest dollar: 40000
Total tax owed is: $4739
Sample run 3:
Enter your salary to the nearest dollar: 100000
Total tax owed is: $18289
Pseudocode
---------------------------------------------------------------------------------------------------------------------------------------------
Screenshot
Program
using System;
namespace FederalTaxCalculatorInCsharp
{
class Program
{
static void
Main(string[] args)
{
//Prompt for salary
Console.Write("Enter your salary to the nearest dollar: ");
int salary= Convert.ToInt32(Console.ReadLine());
//Variable for tax
double tax = 0;
//Each conditons for tax calculaton
if (salary <= 9525)
{
tax = salary * .1;
}
else if (salary > 9525 && salary<=38700)
{
tax = 9525 * .1+(salary-9525)*.12;
}
else if (salary > 38700 && salary <= 82500)
{
tax = 9525 * .1 + (38700-9526) * .12+(salary- 38701)*.22;
}
else if (salary > 82500 && salary <= 157500)
{
tax = 9525 * .1 + (38700 - 9526) * .12 +(82500-38701)*.22+ (salary
- 82501) * .24;
}
else if (salary > 157500 && salary <= 200000)
{
tax = 9525 * .1 + (38700 - 9526) * .12 + (82500 - 38701) *
.22+(157500- 82501)*.24 + (salary - 157501) * .32;
}
else if (salary > 20000 && salary <= 500000)
{
tax = 9525 * .1 + (38700 - 9526) * .12 + (82500 - 38701) * .22 +
(157500 - 82501) * .24 +(200000-157501)*.32+ (salary - 200001) *
.35;
}
else
{
tax = 9525 * .1 + (38700 - 9526) * .12 + (82500 - 38701) * .22 +
(157500 - 82501) * .24 + (200000 - 157501) * .32
+(500000-200001)*.35+ (salary - 500001) * .37;
}
//Display Tax
Console.WriteLine("Total tax owed is: $" +
Convert.ToInt32(tax));
}
}
}
-------------------------------------------------------------------------------------------------
Output
Enter your salary to the nearest dollar: 100000
Total tax owed is: $18289