Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i created a c# program that accepts the category code, number of dependents, tax

ID: 3636383 • Letter: I

Question

i created a c# program that accepts the category code, number of dependents, taxable income and it calculate the tax and it outputs the category and calculated tax, but it has errors, see the code below


categories        category code          Tax

single                      W                12.5% of first 17,850 plus 10% of excess
head of the family    X                 12.5% of first 23,900 plus 10% of excess
married (joint)         Y                 12.5% of first 29,750 plus 10% of excess
married (separate)    Z                12.5% of first 14,875 plus 10% of excess


number of dependents                  Additional Exemption
           1                                             1,500
           2                                              2,300
           3                                             3,100



******************(codes)*********************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string cate1, depend1, taxincom1;
int depend;
float taxincom;
double excess, tax, totaltax1;
Console.WriteLine("category code?");
cate1 = Console.ReadLine();
Console.WriteLine("number of dependents?");
depend1 = Console.ReadLine();
depend = Int32.Parse(depend1);
Console.WriteLine("taxable income?");
taxincom1 = Console.ReadLine();
taxincom = Int32.Parse(taxincom1);


switch (cate1)
{
case "W":
excess = (taxincom - 17850) * 0.10;
tax = (17850 * 0.125) + excess;
if (depend == 1)
totaltax1 = tax - 1500;
else if (depend == 2)
totaltax1 = tax - 2300;
else if (depend == 3)
totaltax1 = tax - 3100;

Console.WriteLine("category code is: {0}", cate1);
Console.WriteLine("number of dependent is: {0}", depend);
Console.WriteLine("taxable income is: {0}", taxincom);
Console.WriteLine("income after tax is: {0}", totaltax1);
break;

case "X":
excess = (taxincom - 23900) * 0.10;
tax = (23900 * 0.125) + excess;
if (depend == 1)
totaltax1 = tax - 1500;
else if (depend == 2)
totaltax1 = tax - 2300;
else if (depend == 3)
totaltax1 = tax - 3100;

Console.WriteLine("category code is: {0}", cate1);
Console.WriteLine("number of dependent is: {0}", depend);
Console.WriteLine("taxable income is: {0}", taxincom);
Console.WriteLine("income after tax is: {0}", totaltax1);
break;

case "Y":
excess = (taxincom - 29750) * 0.10;
tax = (29750 * 0.125) + excess;
if (depend == 1)
totaltax1 = tax - 1500;
else if (depend == 2)
totaltax1 = tax - 2300;
else if (depend == 3)
totaltax1 = tax - 3100;

Console.WriteLine("category code is: {0}", cate1);
Console.WriteLine("number of dependent is: {0}", depend);
Console.WriteLine("taxable income is: {0}", taxincom);
Console.WriteLine("income after tax is: {0}", totaltax1);
break;

case "Z":
excess = (taxincom - 14875) * 0.10;
tax = (14875 * 0.125) + excess;
if (depend == 1)
totaltax1 = tax - 1500;
else if (depend == 2)
totaltax1 = tax - 2300;
else if (depend == 3)
totaltax1 = tax - 3100;

Console.WriteLine("category code is: {0}", cate1);
Console.WriteLine("number of dependent is: {0}", depend);
Console.WriteLine("taxable income is: {0}", taxincom);
Console.WriteLine("income after tax is: {0}", totaltax1);
break;
}
}
}
}

Explanation / Answer

First of all..plz mention the line number of error.. As far as i understood..i think u have given "taxincom as float", but u are typecasting it to integer...(u have writen taxincom = Int32.Parse(taxincom1);) Hope this is helpful...goodluck