I need your help!!!!! HELP ME!!!!

Jan 21 2005 6:00 AM
I meet a c#.net problem, Wish you can help me! I am anxious now!!! I need your help!!!!! For this assignment, you are required to write an object-oriented program that reads a comma-delimited file of Staff Payment Details and stores them in a typed collection. The format of the payment file, Payment.csv, is a comma-delimited file, containing five fields: Staff ID, First Name, Surname, Rate, and worked-hours. You will need to write three files: Payroll.cs, Employee.cs, and PayList.cs. The Payroll class will contain a Main() method that opens the file for reading, creates objects of type Employee to store an individual record read from the payment file, and stores the Employee objects into the PayList typed collection. If an attempt is made to create a Employee with negative Rate or with a worked-hours, or a worked-hours greater than 40 hours, an exception should be thrown and handled (just use the builtin System.Exception type for this purpose). Here are the contents of the stock file, Payment.csv: 1001, Anthony, Wang, 17.50, 36 1002, Helen, Smith, 10.80, 40 1003, John, Newlands, 21, 38 1004, Jackie, Chen, -28.50, 12 1005, Peter, Horan, 21, -17 1006, Robert, Green, 18.50, 30 1007, Justin, Lee, 18.50, 20 1008, Albert, Richmond, 12.50, 25 The output that your program should produce is as follows: Exception occurred: Staff Details: Negative PayRate for Staff ID 1004 Exception occurred: Staff Details: Invalid Worked Hours for Staff ID 1005 Staff Pay List: Staff ID First Name Surname Rate Hours Gross Pay ==================================================== 1001 Anthony , WANG $17.50 * 36 $630.00 1002 Helen , SMITH $10.80 * 40 $432.00 1003 John , NEWLANDS $21.00 * 38 $798.00 1006 Robert , GREEN $18.50 * 30 $555.00 1007 Justin , LEE $18.50 * 20 $370.00 1008 Albert , RICHMOND $12.50 * 25 $312.50 Notes: • The filename of the employee file should be passed as a command line argument - you must display an error if the user does not enter the filename, or if the file does not exist (use the Exists() method of the System.IO.File class) • Invalid employee records are not added to the pay list • Use integer variables to store the worked-hours • For the output, use a field width of t10 for the staff ID and a field width of 10 for the staff name. • Your PayList class should inherit from System.Collections.CollectionBase and should implement a typed Add() method • The employee class should format its data for output • The PayList collection should know how to format the current staff record (the System.Text.StringBuilder class is useful for this) • To split the input from the payment details file into separate fields, use the Split() method of the string class. • You do not need to produce an error message for incorrectly formatted entries in the payment details file (there aren't any).

Answers (3)