Question

In: Computer Science

Create a console application named TakeHomePay.cs under your homework directory (please refer to the earlier recorded...

Create a console application named TakeHomePay.cs under your homework directory (please refer to the earlier recorded Zoom sessions if you are not sure how to do it) that calculates the take-home pay for an employee. The two types of employees are salaried and hourly. Allow the user to input the employee’s first and last name, id, and type. If an employee is salaried, allow the user to input the salary amount. If an employee is hourly, allow the user to input the hourly rate and the number of hours clocked for the week. For hourly employees, overtime is paid for hours over 40 at a rate of 1.5 of the base rate. For all employees’ take-home pay, federal tax of 18% is deducted. A retirement contribution of 10% and a Social Security tax rate of 6% should also be deducted. Use appropriate constants and decision making structures.

Solutions

Expert Solution

C# program to calculate take home pay of an employee based on their type

Code:

using System;
class HelloWorld {
    //defining constants for deductions
    public const double federal_tax=0.18, retirement=0.10, social_security=0.06;
    //main method
    static void Main() {
        //declaring variables
        string first_name, last_name, id, type;
        string user_input;
        double salary=0, hourly_rate, take_home_pay=0;
        int hours_worked;
        //reading first name, last name, ID, and type
        Console.Write("Enter First Name: ");
        first_name=Console.ReadLine();
        Console.Write("Enter Last Name: ");
        last_name=Console.ReadLine();
        Console.Write("Enter ID: ");
        id=Console.ReadLine();
        Console.Write("Enter Type: ");
        type=Console.ReadLine();
        //checking if type is salaried
        if(type=="salaried"){
            //if yes, reading Salary Amount
            Console.Write("Enter Salary Amount: ");
            user_input=Console.ReadLine();
            salary=Convert.ToDouble(user_input);
        }
        //checking if type is hourly
        else if(type=="hourly"){
            //if yes, reading hourly rate and number of hours worked
            Console.Write("Enter Hourly Rate: ");
            user_input=Console.ReadLine();
            hourly_rate=Convert.ToDouble(user_input);
            Console.Write("Enter Number of Hours Worked: ");
            user_input=Console.ReadLine();
            hours_worked=Convert.ToInt32(user_input);
            //checking if hours worked is greater than 40
            if(hours_worked<=40){
                //if not, calculating salary
                salary=hourly_rate*hours_worked;
            }
            //if yes
            else{
                //calculating salary for first 40 hours
                salary=40*hourly_rate;
                //calculating overtime pay for the remaining hours
                double overtime=(hours_worked-40)*(1.5*hourly_rate);
                //calculating total salary
                salary+=overtime;
            }
        }
        //calculating take home pay after the deductions
        take_home_pay=salary-(salary*federal_tax)-(salary*retirement)-(salary*social_security);
        //printing take home pay
        Console.WriteLine("The Take Home Pay is: "+take_home_pay);
    }
}

Code Screenshot:

Output:

1) Salaried Employee:

2) Hourly Employee:


Related Solutions

Part II: gdb (Debugging under Unix) create a new directory named by Inlab6Part2 enter the directory...
Part II: gdb (Debugging under Unix) create a new directory named by Inlab6Part2 enter the directory Inlab6Part2 create a file named by reverse_new.c with the following contents: /*reverse.c */ #include <stdio.h> void reverse(char *before, char *after); main() {       char str[100];    /*Buffer to hold reversed string */       reverse("cat", str); /*Reverse the string "cat" */       printf("reverse(\"cat\")=%s\n", str); /*Display result */       reverse("noon", str); /*Reverse the string "noon" */       printf("reverse(\"noon\")=%s\n", str); /*Display result */       } void reverse(char *before,...
C# Create a console application named that creates a list of shapes, uses serialization to save...
C# Create a console application named that creates a list of shapes, uses serialization to save it to the filesystem using XML, and then deserializes it back: // create a list of Shapes to serialize var listOfShapes = new List<Shape> { new Circle { Colour = "Red", Radius = 2.5 }, new Rectangle { Colour = "Blue", Height = 20.0, Width = 10.0 }, new Circle { Colour = "Green", Radius = 8 }, new Circle { Colour = "Purple",...
~~~USING C# ONLY~~~ Create a console application Design a class named Person with properties for holding...
~~~USING C# ONLY~~~ Create a console application Design a class named Person with properties for holding a person’s name, address, and telephone number. Design a class named Customer, which is derived from the Person class. The Customer class should have the variables and properties for the customer number, customer email, a spentAmount of the customer’s purchases, and a Boolean variable indicating whether the customer wishes to be on a mailing list. It also includes a function named calcAmount that calculates...
UNIX/LINUX SCRIPT: Create a named directory and verify that the directory is there by listing all...
UNIX/LINUX SCRIPT: Create a named directory and verify that the directory is there by listing all its contents. Write a shell script to validate password strength. Here are a few assumptions for the password string.   Length – a minimum of 8 characters. • Contain alphabets , numbers , and @ # $ % & * symbols. • Include both the small and capital case letters. give a prompt of Y or N to try another password and displays an error...
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...
programming language is c#. Create a method that prompts a user of your console application to...
programming language is c#. Create a method that prompts a user of your console application to input the information for a student: static void GetStudentInfo() { Console.WriteLine("Enter the student's first name: "); string firstName = Console.ReadLine(); Console.WriteLine("Enter the student's last name"); string lastName = Console.ReadLine(); // Code to finish getting the rest of the student data ..... } static void PrintStudentDetails(string first, string last, string birthday) { Console.WriteLine("{0} {1} was born on: {2}", first, last, birthday); } 1. Using the...
Create a case (please refer to the sample below) on the application of inferences about the...
Create a case (please refer to the sample below) on the application of inferences about the difference between two population means (σ1 and σ2 unknown) and explain the hypothesis tests until conclusion. EXAMPLE: 22% express an interest in seeing XYZ television show. KL Broadcasting Company ran commercials for this XYZ television show and conducted a survey afterwards. 1532 viewers who saw the commercials were sampled and 414 said that they would watch XYZ television show. What is the point estimate...
Create a file named work.sh in your hw5 directory. Give this file read and write permission...
Create a file named work.sh in your hw5 directory. Give this file read and write permission (no execute permissions) for you alone. No other account should have any access privileges to this file. Change the permissions on the work.sh file so you have read and write permissions. Give everybody else, including the group, read permissions only. Give yourself read, write and execute permissions to the file work.sh. Give everyone else, including the group, execute permissions only. Create a directory named...
:  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:...
Step # 3 - Create the following structure in the home directory: Refer to previous Steps...
Step # 3 - Create the following structure in the home directory: Refer to previous Steps 1 + 2 for reference.   Do a tree to check your work as you go. No GUI, use command line only. Start by creating a directory within the home directory in which to experiment. Do a pwd and make sure you are in /home/pi Make a directory called YourInitials_fun Example: acf_fun In that directory, create a series of files and directories outlined below Make...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT