diff --git a/20240212_valasztas/ConsoleApp1/.vs/ConsoleApp1/v16/.suo b/20240212_valasztas/ConsoleApp1/.vs/ConsoleApp1/v16/.suo new file mode 100644 index 0000000..bf6e7ed Binary files /dev/null and b/20240212_valasztas/ConsoleApp1/.vs/ConsoleApp1/v16/.suo differ diff --git a/20240212_valasztas/ConsoleApp1/App.config b/20240212_valasztas/ConsoleApp1/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/20240212_valasztas/ConsoleApp1/ConsoleApp1.csproj b/20240212_valasztas/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..38ce4b9 --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {48EB5391-192B-4002-8B5E-7C22D38453FA} + Exe + ConsoleApp1 + ConsoleApp1 + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/20240212_valasztas/ConsoleApp1/ConsoleApp1.sln b/20240212_valasztas/ConsoleApp1/ConsoleApp1.sln new file mode 100644 index 0000000..9d8c762 --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/ConsoleApp1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.33529.622 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1.csproj", "{48EB5391-192B-4002-8B5E-7C22D38453FA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {48EB5391-192B-4002-8B5E-7C22D38453FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48EB5391-192B-4002-8B5E-7C22D38453FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48EB5391-192B-4002-8B5E-7C22D38453FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48EB5391-192B-4002-8B5E-7C22D38453FA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {14D65D44-8165-4B4D-AE17-2638E5F4A634} + EndGlobalSection +EndGlobal diff --git a/20240212_valasztas/ConsoleApp1/Program.cs b/20240212_valasztas/ConsoleApp1/Program.cs new file mode 100644 index 0000000..a1f7199 --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/Program.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; + +namespace ConsoleApp1 +{ + public class Kepviselo + { + public int valasztokerulet, szavazatok; + public string nev, part; + public Kepviselo(int szam1, int szam2, string nev, string part) + { + this.valasztokerulet = szam1; + this.szavazatok = szam2; + this.nev = nev; + this.part = part; + } + } + public static class Data + { + public static List kepviselok = new List(); + } + class Program + { + public static void ReadData() + { + FileStream fileStream = new FileStream("..\\szavazatok.txt", FileMode.Open, FileAccess.Read); + StreamReader streamReader = new StreamReader(fileStream); + + string line = streamReader.ReadLine(); + while (line != null) + { + string[] splitted = line.Split(' '); + string nev = $"{splitted[2]} {splitted[3]}"; + Kepviselo kepviselo = new Kepviselo(Convert.ToInt32(splitted[0]), Convert.ToInt32(splitted[1]), nev, splitted[4]); + Data.kepviselok.Add(kepviselo); + line = streamReader.ReadLine(); + } + + streamReader.Close(); + fileStream.Close(); + } + + public static int KepviseloNum() + { + return Data.kepviselok.Count; + } + public static void Feladat2() + { + Console.WriteLine($"A helyhatósági választáson {KepviseloNum()} képviselőjelölt indult."); + } + + public static int SzavazatNum(string kepviselo) + { + foreach (var item in Data.kepviselok) + { + if (item.nev.ToLower() == kepviselo.ToLower()) + { + return item.szavazatok; + } + } + + return -1; + } + public static void Feladat3() + { + Console.WriteLine("Add meg egy képviselő nevét!"); + string name = Console.ReadLine(); + int num = SzavazatNum(name); + if (num >= 0) + { + Console.WriteLine($"{name} nevű képviselőre {num}db szavazatot adtak le."); + } + else + { + Console.WriteLine("Ilyen nevű képviselőjelölt nem szerepel a nyilvántartásban!"); + } + + } + + public static int SzavazokNum() + { + int num = 0; + foreach (var item in Data.kepviselok) + { + num += item.szavazatok; + } + return num; + } + public static void Feladat4() + { + const int jogosultak = 12345; + int num = SzavazokNum(); + double percentage = RoundedPercentage(num, jogosultak); + Console.WriteLine($"A választáson {num} állampolgár, a jogosultak {percentage}%-a vett részt."); + } + + public static double RoundedPercentage(int num, int all) + { + double sol = Convert.ToDouble(num) / Convert.ToDouble(all) * 100; + return Math.Round(sol, 2); + } + + public static void Feladat5() + { + int jogosultak = SzavazokNum(); + int GYEP = 0; + int HEP = 0; + int TISZ = 0; + int ZEP = 0; + int FUG = 0; + foreach (var item in Data.kepviselok) + { + switch (item.part) + { + case "GYEP": + GYEP += item.szavazatok; + break; + case "HEP": + HEP += item.szavazatok; + break; + case "TISZ": + TISZ += item.szavazatok; + break; + case "ZEP": + ZEP += item.szavazatok; + break; + default: + FUG += item.szavazatok; + break; + } + } + + Console.WriteLine($"Gyermek evők pártja: {RoundedPercentage(GYEP, jogosultak)}%"); + Console.WriteLine($"Herpeszesek pártja: {RoundedPercentage(HEP, jogosultak)}%"); + Console.WriteLine($"Tisztáltalanok pártja: {RoundedPercentage(TISZ, jogosultak)}%"); + Console.WriteLine($"Zöldségevők pártja: {RoundedPercentage(ZEP, jogosultak)}%"); + Console.WriteLine($"Független jelöltek: {RoundedPercentage(FUG, jogosultak)}%"); + + } + + public static void Feladat6() + { + List legjobbak = new List(); + int szavazatmax = Data.kepviselok[0].szavazatok; + foreach (var item in Data.kepviselok) + { + if (item.szavazatok > szavazatmax) + { + szavazatmax = item.szavazatok; + } + } + + foreach (var item in Data.kepviselok) + { + if (item.szavazatok == szavazatmax) + { + legjobbak.Add(item); + } + } + + Console.WriteLine($"A legtöbb szavazat: {szavazatmax}db"); + foreach (var item in legjobbak) + { + Console.WriteLine($"{item.nev}, {item.part}"); + } + } + static void Main(string[] args) + { + ReadData(); + Feladat2(); + Feladat3(); + Feladat4(); + Feladat5(); + Feladat6(); + } + } +} + + \ No newline at end of file diff --git a/20240212_valasztas/ConsoleApp1/Properties/AssemblyInfo.cs b/20240212_valasztas/ConsoleApp1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b6c0e8e --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ConsoleApp1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ConsoleApp1")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("48eb5391-192b-4002-8b5e-7c22d38453fa")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.exe b/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.exe new file mode 100644 index 0000000..9275fc0 Binary files /dev/null and b/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.exe differ diff --git a/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.exe.config b/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.exe.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.pdb b/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.pdb new file mode 100644 index 0000000..ed1f600 Binary files /dev/null and b/20240212_valasztas/ConsoleApp1/bin/Debug/ConsoleApp1.pdb differ diff --git a/20240212_valasztas/ConsoleApp1/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/20240212_valasztas/ConsoleApp1/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.AssemblyReference.cache b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.AssemblyReference.cache new file mode 100644 index 0000000..f5e894a Binary files /dev/null and b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.AssemblyReference.cache differ diff --git a/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.CoreCompileInputs.cache b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..ee191d7 --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +7f4b213b428f4c013f19137338418ee1f5525793 diff --git a/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.FileListAbsolute.txt b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..6546469 --- /dev/null +++ b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.csproj.FileListAbsolute.txt @@ -0,0 +1,7 @@ +C:\Users\szabomarton\Desktop\C#\20240212_valasztas\ConsoleApp1\bin\Debug\ConsoleApp1.exe.config +C:\Users\szabomarton\Desktop\C#\20240212_valasztas\ConsoleApp1\bin\Debug\ConsoleApp1.exe +C:\Users\szabomarton\Desktop\C#\20240212_valasztas\ConsoleApp1\bin\Debug\ConsoleApp1.pdb +C:\Users\szabomarton\Desktop\C#\20240212_valasztas\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.AssemblyReference.cache +C:\Users\szabomarton\Desktop\C#\20240212_valasztas\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.CoreCompileInputs.cache +C:\Users\szabomarton\Desktop\C#\20240212_valasztas\ConsoleApp1\obj\Debug\ConsoleApp1.exe +C:\Users\szabomarton\Desktop\C#\20240212_valasztas\ConsoleApp1\obj\Debug\ConsoleApp1.pdb diff --git a/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.exe b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.exe new file mode 100644 index 0000000..9275fc0 Binary files /dev/null and b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.exe differ diff --git a/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.pdb b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.pdb new file mode 100644 index 0000000..ed1f600 Binary files /dev/null and b/20240212_valasztas/ConsoleApp1/obj/Debug/ConsoleApp1.pdb differ diff --git a/20240212_valasztas/ConsoleApp1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/20240212_valasztas/ConsoleApp1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..4b03819 Binary files /dev/null and b/20240212_valasztas/ConsoleApp1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/20240212_valasztas/Valasztas.pdf b/20240212_valasztas/Valasztas.pdf new file mode 100644 index 0000000..1c55ef6 Binary files /dev/null and b/20240212_valasztas/Valasztas.pdf differ diff --git a/20240212_valasztas/szavazatok.txt b/20240212_valasztas/szavazatok.txt new file mode 100644 index 0000000..848297f --- /dev/null +++ b/20240212_valasztas/szavazatok.txt @@ -0,0 +1,40 @@ +5 19 Ablak Antal - +1 120 Alma Dalma GYEP +7 162 Bab Zsuzsanna ZEP +2 59 Barack Barna GYEP +6 73 Birs Helga GYEP +1 154 Bors Botond HEP +5 188 Brokkoli Gyula ZEP +6 29 Ceruza Zsombor - +4 143 Fasirt Ferenc HEP +8 157 Gomba Gitta TISZ +3 13 Halmi Helga - +2 66 Hold Ferenc - +7 34 Hurka Herold HEP +5 288 Joghurt Jakab TISZ +4 77 Kajszi Kolos GYEP +2 187 Kapor Karola ZEP +6 13 Karfiol Ede ZEP +6 187 Kefir Ilona TISZ +7 130 Kupa Huba - +8 98 Languszta Auguszta - +1 34 Lila Lilla - +1 56 Medve Rudolf - +5 67 Meggy Csilla GYEP +3 45 Moly Piroska - +4 221 Monitor Tibor - +8 288 Narancs Edmond GYEP +2 220 Oldalas Olga HEP +3 185 Pacal Kata HEP +1 199 Petrezselyem Petra ZEP +8 77 Pokol Vidor - +8 67 Ragu Ida HEP +3 156 Retek Etelka ZEP +7 129 Sajt Hajnalka TISZ +4 38 Simon Simon - +3 87 Szilva Szilvia GYEP +3 187 Tejes Attila TISZ +2 65 Tejfel Edit TISZ +4 39 Uborka Ubul ZEP +6 288 Vadas Marcell HEP +5 68 Vagdalt Edit HEP