Here is my code:
using System;
using System.IO;
using System.Text.RegularExpressions;
using Util;
namespace Program_9
{
class Program
{
const string INPUT_FILE_NAME = "C:\\Users\\Programing 1\\Soluation 1\\Program 9\\Retirement Numbers\\Input";
const string OUTPUT_FILE_NAME = "C:\\Users\\Programing 1\\Soluation 1\\Program 9\\Retirement Numbers\\Output";
static string lineIn;
static StreamReader fileIn;
static StreamWriter fileOut;
static char WType, WElig;
static uint id;
static int WAge, WExp;
static double numOfEmployees;
static double AvgAge, AvgExp, AgeAvgTotal = 0.0, WAge1Total = 0.0, WAge2Total = 0.0, WAge3Total = 0.0, WAge4Total = 0.0, WAge5Total = 0.0;
static double WAge6Total = 0.0, WAge7Total = 0.0, WAge8Total = 0.0, WAge9Total = 0.0, WAge10Total = 0.0, WAge11Total = 0.0, WAge12Total = 0.0;
static double ExpAvgTotal = 0.0, WExp1Total = 0.0, WExp2Total = 0.0, WExp3Total = 0.0, WExp4Total = 0.0, WExp5Total = 0.0;
static double WExp6Total = 0.0, WExp7Total = 0.0, WExp8Total = 0.0, WExp9Total = 0.0, WExp10Total = 0.0, WExp11Total = 0.0, WExp12Total = 0.0;
static void Main()
{
OpenFiles();
PrintReportHeadings();
while ((lineIn=fileIn.ReadLine()) !=null)
{
ParseLineIn();
PrintDetailLine();
UpdateTotals();
}
CalcAvg();
PrintAvg();
CloseFiles();
DspData();
}
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 exit\n", INPUT_FILE_NAME);
ConIO.Exit();
}
if (File.Exists(OUTPUT_FILE_NAME))
{
fileOut = File.CreateText(OUTPUT_FILE_NAME);
Console.WriteLine("{0} was created\n", OUTPUT_FILE_NAME);
}
else
{
Console.WriteLine("Error: {0} could not be created\n", OUTPUT_FILE_NAME);
ConIO.Exit();
}
}
static void PrintReportHeadings()
{
fileOut.WriteLine("Employee Age Experience Eligibility");
fileOut.WriteLine("{0,9}, {1,7}, {2,7}, {3}", id, WAge, WExp, WElig);
fileOut.WriteLine();
fileOut.WriteLine("Average {0,7:}, {1,7}", AvgAge, AvgExp);
}
static void ParseLineIn(unit id, char WType, double WAge, double WExp, double WElig)
{
string[] words = new string[4];
lineIn = lineIn.Trim();
while (Regex.IsMatch(lineIn, "[ ]{2}"))
lineIn = lineIn.Replace(" ", " ");
words = lineIn.Split(' ');
id = UInt32.Parse(words[0]);
WType = Double.Parse(words[1]);
WAge = Double.Parse(words[2]);
WExp = Double.Parse(words[3]);
}
static void PrintDetailLine()
{
fileOut.WriteLine("{0} {1,7:d} {2,7:d} {3,7:d} {4,7:d} {5,3}",
id, WAge, WExp, WElig);
}
static void UpdateTotals()
{
numOfEmployees++;
WAge1Total += WAge1;
WAge2Total += WAge2;
WAge3Total += WAge3;
WAge4Total += WAge4;
WAge5Total += WAge5;
WAge6Total += WAge6;
WAge7Total += WAge7;
WAge8Total += WAge8;
WAge9Total += WAge9;
WAge10Total += WAge10;
WAge11Total += WAge11;
WAge12Total += WAge12;
AgeAvgTotal += AvgAge;
WExp1Total += WExp1;
WExp2Total += WExp2;
WExp3Total += WExp3;
WExpTotal += WExp4;
WExp5Total += WExp5;
WExp6Total += WExp6;
WExp7Total += WAExp7;
WExp8Total += WExp8;
WExp9Total += WExp9;
WExp10Total += WExp10;
WExp11Total += WExp11;
WExp12Total += WExp12;
ExpAvgTotal += AvgExp;
}
static void CalcAvg()
{
AvgAge = (WAge1 + WAge2 + WAge3 + WAge4 + WAge5 + WAge6 + WAge7 + WAge8 + WAge9 + WAge10 + WAge11 + WAge12) / numOfEmployees;
}
static void CalcAvg()
{
AvgAge = AgeAvgTotal / numOfEmployees;
AvgExp = ExpAvgTotal / numOfEmployees;
}
static void PrintAvg()
{
fileOut.WriteLine(" ");
fileOut.WriteLine("Avg {0,7:f} {1,7:f}", AvgAge, AvgExp);
}
static void CloseFiles()
{
fileIn.Close(); fileOut.Close();
}
static void DspData()
{
switch (WType)
{
case 'W':
case 'w':
if (WAge >= 63 && WExp >= 25)
Console.WriteLine("{0} {1} {2} Employee can retire.", id, WAge, WExp);
else if (WAge >= 63 && WExp < 25)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to lack of experience.", id, WAge, WExp);
else if (WAge < 63 && WExp >= 25)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to being underage.", id, WAge, WExp);
else if (WAge < 63 && WExp < 25)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to being underage and lack of experience.", id, WAge, WExp);
break;
case 'S':
case 's':
if (WAge >= 60 && WExp >= 24)
Console.WriteLine("{0} {1} {2} Employee can retire.", id, WAge, WExp);
else if (WAge >= 60 && WExp < 24)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to lack of experience.", id, WAge, WExp);
else if (WAge < 60 && WExp >= 24)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to being underage.", id, WAge, WExp);
else if (WAge < 60 && WExp < 24)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to being underage and lack of experience.", id, WAge, WExp);
break;
case 'M':
case 'm':
if (WAge >= 55 && WExp >= 20)
Console.WriteLine("{0} {1} {2} Employee can retire.", id, WAge, WExp);
else if (WAge >= 55 && WExp < 20)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to lack of experience.", id, WAge, WExp);
else if (WAge < 55 && WExp >= 20)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to being underage.", id, WAge, WExp);
else if (WAge < 55 && WExp < 20)
Console.WriteLine("{0} {1} {2} Employee cannot retire due to being underage and lack of experience.", id, WAge, WExp);
break;
}
}
}
}
Here is my fineIn:
1235 W 45 20
2536 W 55 21
5894 W 60 30
4597 W 75 35
2597 S 35 10
5689 S 40 20
5489 W 55 39
5872 M 60 40
5569 M 55 25
5566 W 80 20
8865 M 59 35
5598 S 65 35
What I have tried:
Besides everything I can think of, I'm not sure how to fix this. I am a beginner, and my teacher is a stickler for formation so all of my formatting that the program looks like now, I can't change it. I made it in Visual 2015 so the indenting is off a bit.
It is having a problem with the UpdateTotals() in Main(), the static void UpdateTotals() is fine. I can't figure out what I am doing wrong. It just says "There is no argument given that corresponds to the required formal parameter 'WAge1' of 'Program.UpdateTotals()'."