Ошибка Filein и fileout, я не могу этого понять. Пожалуйста, помогите!
Вот мой код:
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; } } } }
Вот мой финеин:
1235 Вт 45 20
2536 Вт 55 21
5894 Вт 60 30
4597 Вт 75 35
2597 с 35 10
5689 с 40 20
5489 Вт 55 39
5872 М 60 40
5569 М 55 25
5566 Вт 80 20
8865 м 59 35
5598 с 65 35
Что я уже пробовал:
Кроме всего, что я могу придумать, я не знаю, как это исправить. Я новичок, и мой учитель-сторонник формирования, поэтому все мое форматирование, на которое сейчас похожа программа, Я не могу изменить. Я сделал это в Visual 2015, так что отступы немного сбились.
Это проблема с UpdateTotals() в Main(), статический недействительными UpdateTotals() нормально. Я не могу понять, что я делаю не так. Он просто говорит: "нет никакого аргумента, соответствующего требуемому формальному параметру "WAge1" программы .UpdateTotals()'."