Question

Has to be written in C#! Write a program that includes an Employee class that can...

Has to be written in C#! Write a program that includes an Employee class that can be used to calculate and print the take-home pay for a commissioned sales employee. Items to include as data members are employee number, first name, last name, and total sales. All employees receive 9% of the total sales of the month. Federal tax rate is 18%. Retirement contribution is 10%. Social Security tax rate is 6%. Use appropriate constants, design an object-oriented solution, and write constructors. Include at least one mutator and one accessor method; provide properties for the other data members. Create a second class, or a driver program, to test your design. Allow the user to enter values for the name of the employee and the sales amount for the month in the driver program as “Mike”, “Johnson”, and $50,000.

Homework Answers

Answer #1

C# Program:

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

namespace commissionedSalesEmployee
{
    //Class definition
    class Employee
    {
        //Member Variables
        private int empNumber;
        private String fName;
        private String lName;
        private double totalSales;

        public const int FederalTaxRate = 18;
        public const int RetirementContribution = 10;
        public const int SocialSecurityTaxRate = 6;

        //Default Constructor
        public Employee()
        {
            empNumber = 0;
            fName = "";
            lName = "";
            totalSales = 0.0;
        }

        //Parameterized constructor
        public Employee(int eNo, String efName, String elName, double sales)
        {
            empNumber = eNo;
            fName = efName;
            lName = elName;
            totalSales = sales;
        }

        //Setter methods
        public void setFirstName(String efName)
        {
            fName = efName;
        }

        //Getter methods
        public void setLastName(String elName)
        {
            lName = elName;
        }

        //Setter methods
        public void setEmpNo(int eNo)
        {
            empNumber = eNo;
        }

        //Setter methods
        public void setSales(double sales)
        {
            totalSales = sales;
        }

        //Getter method
        public int getEmpNo()
        {
            return empNumber;
        }

        //Getter method
        public String getfName()
        {
            return fName;
        }

        //Getter method
        public String getlName()
        {
            return lName;
        }

        //Getter method
        public double getSales()
        {
            return totalSales;
        }

        public double computeTakeHomePay()
        {
            double pay;

            //9% of total sales
            pay = (9 / 100.0) * totalSales;

            //Federal tax rate is 18%
            pay = pay - (pay * (FederalTaxRate / 100.0));

            //Retirement Contribution is 10%
            pay = pay - (pay * (RetirementContribution / 100.0));

            //Social security tax rate is 18%
            pay = pay - (pay * (SocialSecurityTaxRate / 100.0));

            return pay;
        }
    }
  
    //Driver class
    class Program
    {
        //Main method
        static void Main(string[] args)
        {
            //Creating employee object
            Employee emp = new Employee(123, "Mike", "Johnson", 50000);

            //Printing Employee details
            Console.WriteLine("\n Employee Number: " + emp.getEmpNo().ToString());
            Console.WriteLine("\n First Name: " + emp.getfName());
            Console.WriteLine("\n Last Name: " + emp.getlName());
            Console.WriteLine("\n Total Sales: $" + emp.getSales().ToString());
            Console.WriteLine("\n\n Take Home Pay: $" + emp.computeTakeHomePay().ToString() + " \n\n");

            Console.ReadKey();
        }
    }
}

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sample Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
**JAVA LANGUAGE** Write a program that models an employee. An employee has an employee number, a...
**JAVA LANGUAGE** Write a program that models an employee. An employee has an employee number, a name, an address, and a hire date. A name consists of a first name and a last name. An address consists of a street, a city, a state (2 characters), and a 5-digit zip code. A date consists of an integer month, day and year. All fields are required to be non-blank. The Date fields should be reasonably valid values (ex. month 1-12, day...
Write program in C#. WAP on Encapsulation to hide the type members with private access and...
Write program in C#. WAP on Encapsulation to hide the type members with private access and display employee details. • Create a new project, select console application from the template and name the project as “EmployeeDetails.cs”. • Here type members are nothing but properties. • Create another class as Employee and write the properties for EmpId, EmpName and Salary. • Now, create an instance of the Employee class in the “EmployeeDetails” class and assign the values for EmpId,EmpName and Salary...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
write a c++ program A class called car (as shown in the class diagram) contains: o...
write a c++ program A class called car (as shown in the class diagram) contains: o Four private variables: carId (int), carType (String), carSpeed (int) and numOfCars (int). numOfCars is a static counter that should be  Incremented whenever a new Car object is created.  Decremented whenever a Car object is destructed. o Two constructors (parametrized and copy constructor) and one destructor. o Getters and setters for the Car type, ID, and speed. And static getter function for numOfCars....
c++ program. can you please do commenting. Question 1 [25]. (The Account Class) Design a class...
c++ program. can you please do commenting. Question 1 [25]. (The Account Class) Design a class named Account that contains (keep the data fields private): a) An int data field named id for the account. b) A double data field named balance for the account. c) A double data field named annualInterestRate that stores the current interest rate. d) A no-arg constructor that creates a default account with id 0, balance 0, and annualInterestRate 0. e) The accessor and mutator...
The following is for a Java Program Create UML Class Diagram for these 4 java classes....
The following is for a Java Program Create UML Class Diagram for these 4 java classes. The diagram should include: 1) All instance variables, including type and access specifier (+, -); 2) All methods, including parameter list, return type and access specifier (+, -); 3) Include Generalization and Aggregation where appropriate. Java Classes description: 1. User Class 1.1 Subclass of Account class. 1.2 Instance variables __ 1.2.1 username – String __ 1.2.2 fullName – String __ 1.2.3 deptCode – int...
You need to write a permute class that will take first and second strings to rearrange...
You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null. The permute class uses a Node class as link list node to link all letters arrangement. The...
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT