Question

In: Computer Science

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 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 named CalculateFederalTax that will have a return type of double and will accept 1 parameter of type double that 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 named CalculateFICATax that will have a return type of double and will accept 1 parameter 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 named DisplayResults that will have a return type of void and will accept 4 parameters. 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 Rate Taxable 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 Tax Rate = 6.2%

Solutions

Expert Solution

Added 6 Methods
Main
CalculateFederalTax
CalculateFICATax
DisplayResults
input (for take input)
print (for print results)

Code: (Text File also included in End)


Output:


Files:


Code:

using System;

// namespace declaration
namespace TaxAPP {

// Class declaration
class Calculator {

    // Main Method
    static void Main(string[] args) {
        // Variable declaration
        string name;
        double salary;

        // Taking input Name
        print("Enter Your Name:");
        name = input();

        // Taking Salary Input and validating
        print("Enter Your Salary:");
        while(true){ // Run until user give valid salary
            if (double.TryParse(Console.ReadLine(), out salary)) { // User gave valid salary

                double fedralTax = CalculateFederalTax(salary); // calculating Federal Tax
                double ficaTax = CalculateFICATax(salary); // Calculating Fica Tax
                DisplayResults(name, salary, fedralTax, ficaTax); //Printing Results

                break; // Breaking Loo[]

            } else { //user gave an illegal input
                print("Type Valid Salary!");
            }
        }
    }

    // Method for calculate federal Tax
    private static double CalculateFederalTax(double salary){
        double taxPercentage;
        // determining which Federal tax bracket the individual belongs
        if (salary <= 9525){
            taxPercentage = 10;
        }else if (salary <= 38700){
            taxPercentage = 12;
        }else if (salary <= 82500){
            taxPercentage = 22;
        }else if (salary <= 157500){
            taxPercentage = 24;
        }else if (salary <= 200000){
            taxPercentage = 32;
        }else if (salary <= 500000){
            taxPercentage = 35;
        }else {
            taxPercentage = 37;
        }

        return (taxPercentage * salary)/100; // Calculating Federal Tax
    }

    // Method for calculate fica tax
    private static double CalculateFICATax(double salary){
        return (6.2 * salary)/100; // Calculating Fica Tax
    }

    // Method for print results
    private static void DisplayResults(string name, double salary, double fedralTax, double ficaTax){
        print("Name: " + name);
        print("Salary: " + salary);
        print("FedralTax: " + fedralTax);
        print("FicaTax: " + ficaTax);
        print("Net Salary: " + (salary - fedralTax - ficaTax));
    }

    // Method for take input
    private static string input(){
        return Console.ReadLine();
    }

    // Method for print output
    private static void print(string msg){
        Console.WriteLine(msg);
    }
}

}


Related Solutions

C# Create a console application that prompts the user to enter a regular expression, and then...
C# Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a regular expression...
C# & ASP.NET Create a console application that prompts the user to enter a regular expression,...
C# & ASP.NET Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a...
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...
C# Create an application that asks the user to enter their new password. The password must...
C# Create an application that asks the user to enter their new password. The password must be at least 6 characters long. Develop a custom exception handling case that checks for the password length. (hint: use " .Length " built-in method). If the new password is less than 6 characters long the custom exception should output an error message.
Language C++ Ask the user to enter their weight (in pounds) and their height in inches....
Language C++ Ask the user to enter their weight (in pounds) and their height in inches. Calculate their Body Mass Index (BMI) and tell them whether they are underweight, overweight, or at optimal weight. BMI formula: weight * 703 / (height * height) Optimal weight is a BMI from 19 to 26. Lower is underweight, higher is overweight. Prompts: Enter your weight (in pounds): [possible user input: 144] Enter your height (in inches): [posible user input: 73] Possible Outputs: Your...
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...
:  Create a new blank C# console application Your basal metabolic rate is the rate...
:  Create a new blank C# console application Your basal metabolic rate is the rate at which the body uses energy while at rest to keep vital functions going, such as breathing and keeping warm. This calculation is vital to weight management, as it allows you to determine calories needed to maintain, lose, or gain weight. To determine your BMR, use the appropriate formula: Female: 655+(4.35 x weight in pounds)+(4.7 x height in inches)-(4.7 x age in years) Males:...
Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and pass the values to a function that does multiplication
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...
Using (C programming language) Create a health monitoring program, that will ask user for their name,...
Using (C programming language) Create a health monitoring program, that will ask user for their name, age, gender, weight, height and other health related questions like blood pressure and etc. Based on the provided information, program will tell user BMI, blood pressure numbers if they fall in healthy range or not and etc. Suggestions can be made as what should be calorie intake per day and the amount of exercise based on user input data. User should be able to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT