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...
Your application will read in from the user an employee's name and salary, and print out...
Your application will read in from the user an employee's name and salary, and print out a Console Check similar to the following. Your newly modified check printing application will this time accommodate names and numbers of different lengths WITHOUT pushing the left or right hand side of the check out of whack. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > | $1,000,000 | > > > > ___Pay to the Order of___ Johnny PayCheck > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Pease only use technique from chapter 1-4 in C++...
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...
Write a program that does the following in order: 1. Ask user to enter a name...
Write a program that does the following in order: 1. Ask user to enter a name 2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 4. If the sum is greater than 0, print out the sum 5. If the sum is equal to zero, print out “Your account balance is zero” 6. If the sum is less than 0, print out “Your account...
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...
Python3 Write a program to implement the Pokemon game should ask the user to enter their...
Python3 Write a program to implement the Pokemon game should ask the user to enter their type and compare it with a randomly chosen computer type and correctly display who wins/ties.
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.
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,...
Email username generator Write an application that asks the user to enter first name and last...
Email username generator Write an application that asks the user to enter first name and last name. Generate the username from the first five letters of the last name, followed by the first two letters of the first name. Use the .toLowerCase() method to insure all strings are lower case. String aString = “Abcd” aString.toLowerCase(); aString = abcd Use aString.substring(start position, end position + 1) aString.substring(0, 3) yields the first 3 letters of a string If the last name is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT