Question

In: Computer Science

Your Application should ask the user to enter their name and their salary.

Create a C# Console Application, name the solution Homework 6 and the project TaxRate.

Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make sure that they input a correct value (e.g. you need to make sure that salary is a double). If it is invalid, keep prompting them to enter their salary until they comply.

For your Application, you will need to create AT LEAST 3 Methods/Functions (not including the Main method).

  • You need to create a Method namedCalculateFederalTax that will have areturn type of double and will accept 1 parameter of type doublethat will be used to determine the amount of Federal Taxes to be withheld. The method should determine which Federal tax bracket the individual belongs to and return the amount of Federal taxes to be withheld.

  • You need to create a Method namedCalculateFICATax that will have a return type ofdouble and will accept 1parameter of type double that will be used to determine the amount of FICA Taxes to be withheld. The method should return the amount of FICA taxes to be withheld.

  • You need to create a Method namedDisplayResults that will have a return type ofvoid and will accept 4parameters. The method will write a message on the console with the users name, their salary, the amount of Federal Tax that will be withheld, the amount of FICA Tax that will be withheld and their net salary (their salary - all taxes that were withheld). Your parameters should be as follows:

    • Parameter 1 : Type string

    • Parameter 2 : Type double

    • Parameter 3 : Type double

    • Parameter 4 : Type double

Use the information below to figure out what percent to deduct from the users salary for each income tax:

Federal

Tax rateTaxable income bracket
10%$0 to $9,525
12%$9,526 to $38,700
22%$38,701 to $82,500
24%$82,501 to $157,500
32%$157,501 to $200,000
35%$200,001 to $500,000
37%$500,001 or more

FICA - 6.2%


Solutions

Expert Solution

Program:

using System;

namespace taxRate
{
    class Program
    {
        //method to determine the amount of Federal Taxes to be withheld
        public static double CalculateFederalTax(double n)
        {
            if(n<=9525)
                return n*0.01;
            if(n<=38700)
                return n*0.12;
            if(n<=82500)
                return n*0.22;
            if(n<=157500)
                return n*0.24;
            if(n<=200000)
                return n*0.32;
            if(n<=500000)
                return n*0.35;
            return n*0.37;
        }
        //method to determine the amount of FICA Taxes to be withheld
        public static double CalculateFICATax(double n)
        {
            return n*0.062;
        }
        //method to write a message on the console
        public static void DisplayResults(string name, double salary, double fedtax, double ficattax)
        {
            Console.WriteLine("Name: " + name);
            Console.WriteLine("Gross Salary: " + salary);
            Console.WriteLine("Federal Tax: " + fedtax);
            Console.WriteLine("FICA Tax: " + ficattax);
            double netsalary = salary - fedtax - ficattax;
            Console.WriteLine("Net Salary: " + netsalary);
        }
        //main method
        public static void Main(string[] args)
        {
//read name
            Console.Write("Enter Name: ");
            string name = Console.ReadLine();
//read salary
            Console.Write("Enter Salary: ");
            double salary;
            while (!double.TryParse(Console.ReadLine(), out salary))
            {
                Console.Write("Error! Try again : ");
            }
//calculate Federal Tax
            double fedtax = CalculateFederalTax(salary);
//calculate FICA Tax
            double ficattax = CalculateFICATax(salary);
//display the details
            DisplayResults(name, salary, fedtax, ficattax);
            
            Console.ReadKey(true);
        }
    }
}

Output:


Related Solutions

Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
write a program i java that ask the user to enter salary, user ID and username...
write a program i java that ask the user to enter salary, user ID and username and out put them
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
Name the script while.sh. Ask the user to enter a positive integer. You can assume that...
Name the script while.sh. Ask the user to enter a positive integer. You can assume that the user will enter a positive integer (input validation for a positive number not required). Use a while loop to print all integers from 0 up to and including the integer entered. Each integer should be printed on a line by itself and nothing else should print. This is for Linux. I have not done anything on this script. Please help with simplistic commands...
In your python program, ask the user to enter the annual income of an employee and...
In your python program, ask the user to enter the annual income of an employee and the years of experience. Pass these data to a function. The function decides if an employee does qualify for a loan or does not, then it prints a message based on the following rules: If the income is equal or greater than $40000, the function checks if the employee’s years of experience is greater than 4, if so the employee gets $6000 loan; otherwise,...
Java Code: Write an application that takes in user input. (Name, Age, and Salary) ------ Write...
Java Code: Write an application that takes in user input. (Name, Age, and Salary) ------ Write an application that includes a constructor, user input, and operators.
Write a c++ program that ask a user to enter his name and birthday (YYYY/MM/DD). If...
Write a c++ program that ask a user to enter his name and birthday (YYYY/MM/DD). If the age is greater than 21 print "welcome," and if the age is less than 21 print "sorry." Use input validation to make sure the birthdate was entered correctly.
Language C++ Ask the user to enter the name of one primary color (red, blue, yellow)...
Language C++ Ask the user to enter the name of one primary color (red, blue, yellow) and a second primary color that is different from the first. Based on the user's entries, figure out what new color will be made when mixing those two colors. Use the following guide: red and blue make purple blue and yellow make green yellow and red make orange If the user enters anything that is outside one of the above combinations, return an error...
PYTHON Ask the user to enter the number of students in the class. Thereafter ask the...
PYTHON Ask the user to enter the number of students in the class. Thereafter ask the user to enter the student names and scores as shown. Output the name and score of the student with the 2nd lowest score. NOTE: You may assume all students have distinct scores between 0 and 100 inclusive and there are at least 2 students NOTE: You may only use what has been taught in class so far for this assignment. You are not allowed...
Q3) ​Write a main function to test your SortTriple will ask the user to enter the...
Q3) ​Write a main function to test your SortTriple will ask the user to enter the three values, then uses ​SortTriple ​to reorder the values if required. The main function should print the value in the correct order and a message to indicate if the values were in the correct order or not. ​[20 points] ● You are NOT allowed to use loops or arrays in your code​ ​[- 30 points] ● You are ​NOT​ allowed to use global variables....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT