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,...
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,...
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...
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...
Create a C# application You are to create a class object called “Employee” which included eight...
Create a C# application You are to create a class object called “Employee” which included eight private variables: firstN lastN dNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week. regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods:  constructor  properties  CalcPay(): Calculate the regular...
For this assignment, you need to submit a Python program that gathers the following employee information...
For this assignment, you need to submit a Python program that gathers the following employee information according to the rules provided: Employee ID (this is required, and must be a number that is 7 or less digits long) Employee Name (this is required, and must be comprised of primarily upper and lower case letters. Spaces, the ' and - character are all allowed as well. Employee Email Address (this is required, and must be comprised of primarily of alphanumeric characters....
DATA STRUCTURE /C++ Write a program that allows the user to enter the last names offive...
DATA STRUCTURE /C++ Write a program that allows the user to enter the last names offive candidates in a local election and the votes received by each candidate. The program should then output each candidate’s name, votes received by that candidate, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is as follows: Candidate Johnson Miller Duffy Robinson Sam Total Votes Received 5000 4000 6000...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT