Guest User

Untitled

a guest
Dec 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace CIS247A_Week_5_Lab
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. /*
  13. *********************************
  14. * Programming Week Lab 4 *
  15. * Employee lab *
  16. * Developer Dave Hager *
  17. * Date Completed 10/2/2012 *
  18. *********************************
  19. */
  20.  
  21. //Constructors
  22. Employee empData = new Employee();
  23. Employee empData2 = new Employee("Mary", "Noia", 'F', 5, 24000);
  24. Benefit benefit1 = new Benefit("Full", 1000, 5);
  25. Salary1 salary1 = new Salary1();
  26.  
  27. Console.WriteLine("******** Enter Employee Data ********");
  28.  
  29. //Methods
  30. GetFirstName(empData);
  31. GetLastName(empData);
  32. Gender(empData);
  33. Dependants(empData);
  34. GetSalaryData(empData);
  35. HealthInsurance(empData);
  36. string output = empData.ToString();
  37. Console.WriteLine(output);
  38. //string output1 = empData.Benefit.ToString();
  39. //Console.WriteLine(output1);
  40. string output2 = empData2.ToString();
  41. Console.WriteLine(output2);
  42.  
  43. //Employee.GetNumberEmployees();
  44. TerminateApplication();
  45. }
  46.  
  47. private static string GetFirstName(Employee empData)//Get First Name Method
  48. {
  49. string firstName = "";
  50. Console.Write("\nFirst name: ");
  51. firstName = Console.ReadLine();
  52. empData.FirstName = firstName;
  53. return firstName;
  54. }
  55.  
  56. private static string GetLastName(Employee empData)//Get Last Name Method
  57. {
  58. string lastName = "";
  59. Console.Write("\nLast name: ");
  60. lastName = Console.ReadLine();
  61. empData.LastName = lastName;
  62. return lastName;
  63. }
  64.  
  65. private static char Gender(Employee empData)//Get Gender Method
  66. {
  67. char gender;
  68. Console.Write("\nGender: ");
  69. gender = Convert.ToChar(Console.ReadLine());
  70. empData.Gender = gender;
  71. return gender;
  72. }
  73.  
  74. private static int Dependants(Employee empData)//Get Dependants Method
  75. {
  76. Console.Write("\nDependants: ");
  77. int dependants = Convert.ToInt32(Console.ReadLine());
  78. empData.Dependants = dependants;
  79. return dependants;
  80. }
  81.  
  82. public static void GetSalaryData(Employee empData)
  83. {
  84. string employeePay = string.Empty;
  85. Console.Write("\nSalary or Hourly?");
  86. employeePay = Console.ReadLine();
  87. Console.WriteLine();
  88.  
  89. if (employeePay.ToLower() == "salary")
  90. {
  91. AnnualSalary(empData);
  92. }
  93.  
  94. else if (employeePay.ToLower() == "hourly")
  95. {
  96.  
  97. HourlyPay(empData);
  98.  
  99. }
  100. }
  101.  
  102. private static string HealthInsurance(Employee empData)
  103. {
  104. string healthInsurance = "";
  105. Console.Write("\nHealth Insurance: ");
  106. healthInsurance = Console.ReadLine();
  107. return healthInsurance;
  108.  
  109. }
  110.  
  111. private static double AnnualSalary(Employee empData)//Get Annual Salary Method
  112. {
  113.  
  114. Console.Write("\nAnnual Salary: ");
  115. double salary = Convert.ToDouble(Console.ReadLine());
  116. empData.AnnualSalary = salary;
  117. return salary;
  118. }
  119.  
  120. private static double HourlyPay(Employee empData)
  121. {
  122. Console.Write("\nAmount per hour: ");
  123. double hours = Convert.ToDouble(Console.ReadLine());
  124. empData.AnnualSalary = hours * 2080;
  125. return hours;
  126. }
  127.  
  128. private static void TerminateApplication()//Terminate Method
  129. {
  130. Console.WriteLine("\nHit Enter to Close Window");
  131. Console.ReadLine();
  132. }
  133.  
  134. }
  135. }
  136.  
  137.  
  138. using System;
  139. using System.Collections.Generic;
  140. using System.Linq;
  141. using System.Text;
  142.  
  143. namespace CIS247A_Week_5_Lab
  144. {
  145. public class Employee: Benefit
  146. {
  147. //Private Employee Data
  148. private string firstName;
  149. private string lastName;
  150. private char gender;
  151. private int dependants;
  152. private double annualSalary;
  153. public static int numEmployees = 0;
  154. Benefit benefit = new Benefit();
  155.  
  156.  
  157.  
  158.  
  159. //Default Constructor
  160. public Employee()
  161. {
  162. firstName = "not given ";
  163. lastName = "not given";
  164. gender = 'U';
  165. dependants = 0;
  166. annualSalary = 20000;
  167.  
  168. }
  169.  
  170. //Argumented Constructor
  171. public Employee(string first, string last, char gender, int dependants, double salary)
  172. {
  173. firstName = first;
  174. lastName = last;
  175. Gender = gender;
  176. Dependants = dependants;
  177. AnnualSalary = salary;
  178. }
  179.  
  180. public Benefit Benefit
  181. {
  182. set
  183. { benefit = value; }
  184. get
  185. { return benefit; }
  186. }
  187. //Property First Name
  188. public string FirstName
  189. {
  190. set
  191. {firstName = value;}
  192. get
  193. {return firstName;}
  194. }
  195.  
  196. //Property Last Name
  197. public string LastName
  198. {
  199. set
  200. { lastName = value; }
  201. get
  202. { return lastName; }
  203. }
  204.  
  205. //Property Gender
  206. public char Gender
  207. {
  208. set
  209. { gender = value; }
  210. get
  211. { return gender; }
  212. }
  213.  
  214. //Property Dependants
  215. public int Dependants
  216. {
  217. set
  218. { dependants = value; }
  219. get
  220. { return dependants; }
  221. }
  222.  
  223. //Annual Salary
  224. public double AnnualSalary
  225. {
  226. set
  227. { annualSalary = value; }
  228. get
  229. { return annualSalary; }
  230. }
  231.  
  232. //Calculates Weekly Pay
  233. public double CalculatePay()
  234. {
  235. return annualSalary / 52;
  236. }
  237.  
  238.  
  239.  
  240. public static int GetNumberEmployees()
  241. {
  242. return numEmployees;
  243. }
  244.  
  245.  
  246.  
  247. //Displays Employee Data
  248. public override string ToString()
  249. {
  250. string output;
  251. numEmployees++;
  252. output = "\n******** Employee Information ********\n";
  253. output += "\nFirst Name; " + firstName;
  254. output += "\nLast Name; " + lastName;
  255. output += "\nGender; " + gender;
  256. output += "\nDependants; " + dependants;
  257. output += "\nAnnual Salary; " + annualSalary.ToString("C2");
  258. output += "\nWeekly Pay: " + CalculatePay().ToString("C2");
  259.  
  260. output += Benefit.ToString();
  261. return output;
  262. }
  263. }
  264. }
  265.  
  266.  
  267. using System;
  268. using System.Collections.Generic;
  269. using System.Linq;
  270. using System.Text;
  271.  
  272. namespace CIS247A_Week_5_Lab
  273. {
  274. public class Benefit
  275. {
  276. private string healthInsurance;
  277. private double lifeInsurance;
  278. private int vacation;
  279.  
  280. public Benefit()
  281. {
  282. healthInsurance = "Partial";
  283. lifeInsurance = 500;
  284. vacation = 10;
  285. }
  286.  
  287.  
  288. public Benefit(string health, double life, int vac)
  289. {
  290. HealthInsurance = health;
  291. LifeInsurance = life;
  292. Vacation = vac;
  293. }
  294.  
  295. public string HealthInsurance
  296. {
  297. set
  298. { healthInsurance = value; }
  299. get
  300. { return healthInsurance; }
  301. }
  302.  
  303. public double LifeInsurance
  304. {
  305. set
  306. {lifeInsurance = value; }
  307. get
  308. { return lifeInsurance; }
  309. }
  310.  
  311. public int Vacation
  312. {
  313. set
  314. { vacation = value; }
  315. get
  316. { return vacation; }
  317. }
  318.  
  319.  
  320.  
  321. public override string ToString()
  322. {
  323. string output;
  324. output = "\n Health Insurance: " + healthInsurance;
  325. output = "\nLife Insurance; " + lifeInsurance;
  326. output = "\nVacation; " + Vacation;
  327. output = "\nTotal Employees: " + Employee.numEmployees;
  328. return output;
  329. }
  330. }
  331. }
Add Comment
Please, Sign In to add comment