Skip to content

C# Programming ChapterCce Exercises;; HELPP

Mikee Gutierrez

Mikee Gutierrez

Asked Jun 15, 2015, 3:07 PM EDT4 answers
Share
LinkedInX
1.  Create a class representing a student. Include characteristics such student number, first, and last name, overall GPA, classification, and major. Write at least two constructors. Include properties for each of the data items. Create a second class that instantiates the first class with information about yourself. In the second class, create a class method that displays your name and GPA.
 
 
 
 
2. Create an Employee class. Items to include as data members are employee number, name, date of hire, job description, department, and monthly salary. The class is often used to display an alphabetical listing of all employees. Include appropriate constructors and properties. Override the ToString() method to return all data members. Create a second class to test your Employee class.
 
 
3. 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. All employee receive 7% of the total sales. Federal tax rate is 18%. Retirement contribution is 10%. Social Security tax rate is 6%. Write instance methods to calculate the commission income, federal, and social security tax withholding amounts and the amount withheld for retirement. 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 instance variables. Create a second class to test your design. Allow the user to enter values for the name of the employee and the sales amount for the week in the second class.

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mikee Gutierrez
    0
    /*
    * Create a class representing a student. Include characteristics such as student
    number, first and last name, overall GPA, classification, and major. Write at least
    two constructors. Include properties for each of the data items. Create a second
    TypeScript
    class that instantiates the first class with information about yourself. In the
    second class, create a class method that displays your name and GPA.
     */
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace StudentInformation
    {
        public class StudentInfo
        {
            private int studentNumber;
            private string firstName;
            private string lastName;
            private double studentGPA;
            private string studentClass;
            private string studentMajor;
    
            public int StudentNumber
            {
    get
    TypeScript
                {
                    return studentNumber;
                }
            }
    
            public void setFirstName(String newFirstName)
            {
                firstName = newFirstName;
            }
    
            public string FirstName
            {
                get
                {
                    return firstName;
                }
            }
    
             public void setLastName(String newLastName)
            {
                lastName = newLastName;
            }
    
            public string LastName
            {
    get
    C#
                {
                    return lastName;
                }
            }
    
            public double StudentGPA
            {
                get
                {
                    return studentGPA;
                }
            }
    
            public string StudentClass
            {
    get
    C#
                {
                    return studentClass;
                }
            }
    
            public string StudentMajor
            {
                get
                {
                    return studentMajor;
                }
            }
    
            //Default Constructor
            public StudentInfo()
            {
            }
    
            //Constructor 1
            public StudentInfo(int number, string first, string last,
                                double gpa, string classification, string major)
            {
                studentNumber = number;
                firstName = first;
                lastName = last;
                studentGPA = gpa;
                studentClass = classification;
                studentMajor = major;
            }
    
            //Constructor 2
            public StudentInfo(string first, string last, double gpa)
            {
                firstName = first;
                lastName = last;
                studentGPA = gpa;
            }
        }
    }
    
    
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace StudentInformation
    {
        public class StudentInformation
        {
            public static void Main()
            {
                StudentInfo Dustin = new StudentInfo();
                Console.WriteLine("Name: " + Dustin.FirstName + " " + Dustin.LastName + "\n"+ "GPA: " + Dustin.StudentGPA);
                Console.ReadKey();
            }
    
        }
    }
    0
  • Mikee Gutierrez
    0

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

    namespace EmployeeProgram
    {
    public class employee
    {
    private int employeeNumber;
    private string name;
    private string hiredate;
    private int monthlySalary;
    private string description;
    private string department;

    public employee(int employeeNumber, string name, string dateOfHire, int monthlySalary, string description, string department)
    {

    this.employeeNumber = 321;
    this.name = "Alex";
    this.hiredate = "01/02/15";
    this.monthlySalary = 2500;
    this.description = "Corporate grunt";
    this.department = "Sales";
    }

    public int EmployeeNumber
    {
    get
    {
    return employeeNumber;
    }
    set
    {
    employeeNumber = value;
    }
    }

    public string Name
    {
    get
    {
    return name;
    }
    set
    {
    name = value;
    }
    }

    public string Hiredate
    {
    get
    {
    return hiredate;
    }
    set
    {
    hiredate = value;
    }
    }

    public int MonthlySalary
    {
    get
    {
    return monthlySalary;
    }
    set
    {
    monthlySalary = value;
    }
    }
    public string Department
    {
    get
    {
    return department;
    }
    set
    {
    department = value;
    }
    }
    public string Description
    {
    get
    {
    return description;
    }
    set
    {
    description = value;
    }
    }

    public override string ToString()
    {
    return "Employee ID: " + employeeNumber +
    "Employee Name: " + name +
    "Employee Hire Date: " + hiredate +
    "Employee Monthly Salary: " + monthlySalary +
    "Employee Description: " + description +
    "Employee Department: " + department;
    }

    public void Print()
    {
    Console.WriteLine(this.ToString());
    }
    }

    0
  • Mikee Gutierrez
    0
    Int32 weeklySales = 0;

    while (weeklySales.Equals(0))
    {
    Console.WriteLine("What are your weekly sales?");
    String input = Console.ReadLine();

    try
    {
    weeklySales = Int32.Parse(input);
    }
    catch
    {
    Console.WriteLine("There is an error in your input, try again!");
    }
    }

    Double grossPay = weeklySales * .07;
    Double fedTax = grossPay * .18;
    Double retirement = grossPay * .1;
    Double socSecurity = grossPay * .06;
    Double totDeductions = socSecurity + retirement + fedTax;
    Double takeHomePay = grossPay - totDeductions;

    Console.Write("\nYour Weekly Sale amount is :" + weeklySales + "$\nGross Pay: " + grossPay + "$\nFed Tax: " + fedTax + "$\nRetirement: " + retirement + "$\nSocial Security: " + socSecurity + "$\nTotal Deductions: " + totDeductions + "$\nMaking your take home pay: " + takeHomePay + "$");
    0
  • 0
    the code looks ok but i can't see the second class "Create a second class to test your Employee class"
    0