Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace CIS247A_Week_5_Lab
- {
- class Program
- {
- static void Main(string[] args)
- {
- /*
- *********************************
- * Programming Week Lab 4 *
- * Employee lab *
- * Developer Dave Hager *
- * Date Completed 10/2/2012 *
- *********************************
- */
- //Constructors
- Employee empData = new Employee();
- Employee empData2 = new Employee("Mary", "Noia", 'F', 5, 24000);
- Benefit benefit1 = new Benefit("Full", 1000, 5);
- Salary1 salary1 = new Salary1();
- Console.WriteLine("******** Enter Employee Data ********");
- //Methods
- GetFirstName(empData);
- GetLastName(empData);
- Gender(empData);
- Dependants(empData);
- GetSalaryData(empData);
- HealthInsurance(empData);
- string output = empData.ToString();
- Console.WriteLine(output);
- //string output1 = empData.Benefit.ToString();
- //Console.WriteLine(output1);
- string output2 = empData2.ToString();
- Console.WriteLine(output2);
- //Employee.GetNumberEmployees();
- TerminateApplication();
- }
- private static string GetFirstName(Employee empData)//Get First Name Method
- {
- string firstName = "";
- Console.Write("\nFirst name: ");
- firstName = Console.ReadLine();
- empData.FirstName = firstName;
- return firstName;
- }
- private static string GetLastName(Employee empData)//Get Last Name Method
- {
- string lastName = "";
- Console.Write("\nLast name: ");
- lastName = Console.ReadLine();
- empData.LastName = lastName;
- return lastName;
- }
- private static char Gender(Employee empData)//Get Gender Method
- {
- char gender;
- Console.Write("\nGender: ");
- gender = Convert.ToChar(Console.ReadLine());
- empData.Gender = gender;
- return gender;
- }
- private static int Dependants(Employee empData)//Get Dependants Method
- {
- Console.Write("\nDependants: ");
- int dependants = Convert.ToInt32(Console.ReadLine());
- empData.Dependants = dependants;
- return dependants;
- }
- public static void GetSalaryData(Employee empData)
- {
- string employeePay = string.Empty;
- Console.Write("\nSalary or Hourly?");
- employeePay = Console.ReadLine();
- Console.WriteLine();
- if (employeePay.ToLower() == "salary")
- {
- AnnualSalary(empData);
- }
- else if (employeePay.ToLower() == "hourly")
- {
- HourlyPay(empData);
- }
- }
- private static string HealthInsurance(Employee empData)
- {
- string healthInsurance = "";
- Console.Write("\nHealth Insurance: ");
- healthInsurance = Console.ReadLine();
- return healthInsurance;
- }
- private static double AnnualSalary(Employee empData)//Get Annual Salary Method
- {
- Console.Write("\nAnnual Salary: ");
- double salary = Convert.ToDouble(Console.ReadLine());
- empData.AnnualSalary = salary;
- return salary;
- }
- private static double HourlyPay(Employee empData)
- {
- Console.Write("\nAmount per hour: ");
- double hours = Convert.ToDouble(Console.ReadLine());
- empData.AnnualSalary = hours * 2080;
- return hours;
- }
- private static void TerminateApplication()//Terminate Method
- {
- Console.WriteLine("\nHit Enter to Close Window");
- Console.ReadLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace CIS247A_Week_5_Lab
- {
- public class Employee: Benefit
- {
- //Private Employee Data
- private string firstName;
- private string lastName;
- private char gender;
- private int dependants;
- private double annualSalary;
- public static int numEmployees = 0;
- Benefit benefit = new Benefit();
- //Default Constructor
- public Employee()
- {
- firstName = "not given ";
- lastName = "not given";
- gender = 'U';
- dependants = 0;
- annualSalary = 20000;
- }
- //Argumented Constructor
- public Employee(string first, string last, char gender, int dependants, double salary)
- {
- firstName = first;
- lastName = last;
- Gender = gender;
- Dependants = dependants;
- AnnualSalary = salary;
- }
- public Benefit Benefit
- {
- set
- { benefit = value; }
- get
- { return benefit; }
- }
- //Property First Name
- public string FirstName
- {
- set
- {firstName = value;}
- get
- {return firstName;}
- }
- //Property Last Name
- public string LastName
- {
- set
- { lastName = value; }
- get
- { return lastName; }
- }
- //Property Gender
- public char Gender
- {
- set
- { gender = value; }
- get
- { return gender; }
- }
- //Property Dependants
- public int Dependants
- {
- set
- { dependants = value; }
- get
- { return dependants; }
- }
- //Annual Salary
- public double AnnualSalary
- {
- set
- { annualSalary = value; }
- get
- { return annualSalary; }
- }
- //Calculates Weekly Pay
- public double CalculatePay()
- {
- return annualSalary / 52;
- }
- public static int GetNumberEmployees()
- {
- return numEmployees;
- }
- //Displays Employee Data
- public override string ToString()
- {
- string output;
- numEmployees++;
- output = "\n******** Employee Information ********\n";
- output += "\nFirst Name; " + firstName;
- output += "\nLast Name; " + lastName;
- output += "\nGender; " + gender;
- output += "\nDependants; " + dependants;
- output += "\nAnnual Salary; " + annualSalary.ToString("C2");
- output += "\nWeekly Pay: " + CalculatePay().ToString("C2");
- output += Benefit.ToString();
- return output;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace CIS247A_Week_5_Lab
- {
- public class Benefit
- {
- private string healthInsurance;
- private double lifeInsurance;
- private int vacation;
- public Benefit()
- {
- healthInsurance = "Partial";
- lifeInsurance = 500;
- vacation = 10;
- }
- public Benefit(string health, double life, int vac)
- {
- HealthInsurance = health;
- LifeInsurance = life;
- Vacation = vac;
- }
- public string HealthInsurance
- {
- set
- { healthInsurance = value; }
- get
- { return healthInsurance; }
- }
- public double LifeInsurance
- {
- set
- {lifeInsurance = value; }
- get
- { return lifeInsurance; }
- }
- public int Vacation
- {
- set
- { vacation = value; }
- get
- { return vacation; }
- }
- public override string ToString()
- {
- string output;
- output = "\n Health Insurance: " + healthInsurance;
- output = "\nLife Insurance; " + lifeInsurance;
- output = "\nVacation; " + Vacation;
- output = "\nTotal Employees: " + Employee.numEmployees;
- return output;
- }
- }
- }
Add Comment
Please, Sign In to add comment