Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help answer this c sharp programming questions ASAP. The questions are in the comments in the code. I added the file needed for

I need help answer this c sharp programming questions ASAP. The questions are in the comments in the code. I added the file needed for this, and the questions are in bold. I hope this makes sense. If you have to modify or adjust the code below to complete this, please do. I need this done ASAP.

Here is the payroll data file info:

image text in transcribed

Here is the code:

/* Purpose: Process payroll report using parallel arrays. */

using System; using System.IO; using System.Text.RegularExpressions; using LibUtil;

// The application class class Ch7Prb1 {

const double FICA_RATE = 0.07; const double FED_TAX_RATE = 0.22; const double STATE_TAX_RATE = 0.05; const string INPUT_FILE_NAME = "...\\...\\PayrollDat.Txt"; const string OUTPUT_FILE_NAME = "...\\...\\PayrollReport.Txt";

static uint numOfEmployees; static string[] lastNameArray = new string[51], firstNameArray = new string[51]; static uint[] deptArray = new uint[51]; static double[] rateArray = new double[51], hoursArray = new double[51]; static double[] earningsArray = new double[51], ficaArray = new double[51]; static double[] fedTaxArray = new double[51], stateTaxArray = new double[51]; static double[] netPayArray = new double[51]; static StreamReader fileIn; static StreamWriter fileOut;

static void Main() { OpenFiles(); InputData(); CalcDetailPayroll(); PrintReport(); CloseFiles(); }

static void OpenFiles() { if (File.Exists(INPUT_FILE_NAME)) { fileIn = File.OpenText(INPUT_FILE_NAME); Console.WriteLine("{0} was opened",INPUT_FILE_NAME); } else { Console.WriteLine("Error: {0} does not exist ",INPUT_FILE_NAME); ConsoleApp.Exit(); } fileOut = File.CreateText(OUTPUT_FILE_NAME); if (File.Exists(OUTPUT_FILE_NAME)) Console.WriteLine("{0} was created ",OUTPUT_FILE_NAME); else { Console.WriteLine("Error: {0} could not be created ",OUTPUT_FILE_NAME); ConsoleApp.Exit(); } }

static void ParseLineIn(string lineIn, uint i) { string[] words = new string[5];

lineIn = lineIn.Trim(); while (Regex.IsMatch(lineIn,"[ ]{2}")) lineIn = lineIn.Replace(" "," "); words = lineIn.Split(' '); lastNameArray[i] = words[0]; //Add code to read in data into remaining arrays }

static void InputData() { uint i; string lineIn;

i = 0; while ((lineIn=fileIn.ReadLine())!=null) { i++; ParseLineIn(lineIn,i); } numOfEmployees = i; }

static void CalcDetailPayroll() { uint i; double basePay,ovtPay;

for (i=1; i//Calculate earnings, fica, fedTax, stateTax, and netPay } }

static double Total(double[] doubleArray) { }

static double Mean(double[] doubleArray) { uint i; double sum=0.0;

for (i=1; i

static double Max(double[] doubleArray) { uint i; double max;

max = doubleArray[1]; for (i=2; imax) max = doubleArray[i]; return max; }

static double Min(double[] doubleArray) { }

static void PrintReport() { uint i;

fileOut.WriteLine(" Payroll Report "); fileOut.WriteLine(); fileOut.WriteLine(" Last Name First Name Dept Rate Hours Earnings FICA Fed Tax State Tax Net Pay "); fileOut.WriteLine("--------------- --------------- ---- ----- ----- --------- --------- --------- --------- ---------"); //Create for loop to display last name, firstname, dept, rate, hours, earnings fica, fedTax, stateTax, and netPay fileOut.WriteLine(" --------- --------- --------- --------- ---------"); fileOut.WriteLine("{0,-49}{1,9:n} {2,9:n} {3,9:n} {4,9:n} {5,9:n}", "Total",Total(earningsArray),Total(ficaArray), Total(fedTaxArray),Total(stateTaxArray),Total(netPayArray)); fileOut.WriteLine("{0,-49}{1,9:n} {2,9:n} {3,9:n} {4,9:n} {5,9:n}", "Mean",Mean(earningsArray),Mean(ficaArray), Mean(fedTaxArray),Mean(stateTaxArray),Mean(netPayArray)); fileOut.WriteLine("{0,-49}{1,9:n} {2,9:n} {3,9:n} {4,9:n} {5,9:n}", "Maximum",Max(earningsArray),Max(ficaArray), Max(fedTaxArray),Max(stateTaxArray),Max(netPayArray)); fileOut.WriteLine("{0,-49}{1,9:n} {2,9:n} {3,9:n} {4,9:n} {5,9:n}", "Minimum",Min(earningsArray),Min(ficaArray), Min(fedTaxArray),Min(stateTaxArray),Min(netPayArray)); }

static void CloseFiles() { fileIn.Close(); fileOut.Close(); }

}

end of code..........

This should be the desired output, if done correctly:

image text in transcribed

John PayrollDat - Notepad File Edit Format View Help Adams Paul Allen Cindy Allen Sarah Baker Baker Toni Baldwin Cindy Carson Robert Freeman Sally Garfield James Grimes Kerri Harris Joan Harris John Lawson LeAnn Mason Debbie Masters Kenneth Patterson Roseanne Peterson Paul Randall Michael Rogers Sherry Shepard Steven 3 2 4 1 1 2 1 4 3 3 2 2 4 4 3 2 2 3 1 3 9.75 11.45 10.30 22.00 12.65 7.90 8.35 15.25 22.00 16.50 18.65 9.00 17.85 22.00 16.10 13.70 22.00 8.00 16.50 10.90 40.00 48.00 40.00 43.25 40.00 25.50 52.50 40.00 40.00 35.00 51.00 47.50 40.00 41.50 40.25 38.00 44.00 41.00 30.00 45.50 Payroll Report Last Name First Name Dept Rate Hours Earnings FICA Fed Tax State Tax Net Pay 3 2 4 1 1 Adams Allen Allen Baker Baker Baldwin Carson Freeman Garfield Grimes Harris Harris Lawson Mason Masters Pattersor Peterson Randall Rogers Shepard Paul Cindy Sarah John Toni Cindy Robert Sally James Kerri Joan John LeAnn Debbie Kenneth nne Paul Michael Sherry Steven 2 1 4 3 3 2 9.75 40.00 390.00 11.45 48.00 595.40 10.30 40.00 412.00 22.00 43.25 987.25 12.65 40.00 506.00 7.90 25.50 201.45 8.35 52.50 490.56 15.25 40.00 610.00 22.00 40.00 880.00 16.50 35.00 577.50 18.65 51.00 1,053.72 9.00 47.50 461.25 17.85 40.00 714.00 22.00 41.50 929.50 16.10 40.25 650.04 13.70 38.00 520.60 22.00 44.00 1,012.00 8.00 41.00 332.00 16.50 30.00 495.00 10.90 45.50 525.93 27.30 41.68 28.84 69.11 35.42 14.10 34.34 42.70 61.60 40.43 73.76 32.29 49.98 65.07 45.50 36.44 70.84 23.24 34.65 36.82 85.80 130.99 90.64 217.20 111.32 44.32 107.92 134.20 193.60 127.05 231.82 101.48 157.08 204.49 143.01 114.53 222.64 73.04 108.90 115.70 19.50 29.77 20.60 49.36 25.30 10.07 24.53 30.50 44.00 28.88 52.69 23.06 35.70 46.48 32.50 26.03 50.60 16.60 24.75 26.30 257.40 392.96 271.92 651.58 333.96 132.96 323.77 402.60 580.80 381.14 695.45 384.42 471.24 613.46 429.03 343.60 667.92 219.12 326.70 347.11 2 4 4 3 2 2 3 1 3 Total Mean Maximum Minimum 12,344.20 617.21 1,053.72 201.45 864.11 43.21 73.76 14.10 2,715.73 135.79 231.82 44.32 617.22 8,147.14 30.86 407.36 52.69 695.45 10.07 132.96

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions