added karacsonyi disz feladat

main
szabomarton 3 months ago
parent 1a5ea6593f
commit 38d9ffda29

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F8DF1118-704F-41A4-A645-2FAFC96EB37F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApp1</RootNamespace>
<AssemblyName>ConsoleApp1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -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", "{F8DF1118-704F-41A4-A645-2FAFC96EB37F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F8DF1118-704F-41A4-A645-2FAFC96EB37F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8DF1118-704F-41A4-A645-2FAFC96EB37F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8DF1118-704F-41A4-A645-2FAFC96EB37F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8DF1118-704F-41A4-A645-2FAFC96EB37F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C04D3A23-72E7-4246-A9F1-83BCCCD63D0D}
EndGlobalSection
EndGlobal

@ -0,0 +1,211 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApp1
{
public class NapiMunka
{
public static int KeszultDb { get; private set; }
public int Nap { get; private set; }
public int HarangKesz { get; private set; }
public int HarangEladott { get; private set; }
public int AngyalkaKesz { get; private set; }
public int AngyalkaEladott { get; private set; }
public int FenyofaKesz { get; private set; }
public int FenyofaEladott { get; private set; }
public NapiMunka(string sor)
{
string[] s = sor.Split(';');
Nap = Convert.ToInt32(s[0]);
HarangKesz = Convert.ToInt32(s[1]);
HarangEladott = Convert.ToInt32(s[2]);
AngyalkaKesz = Convert.ToInt32(s[3]);
AngyalkaEladott = Convert.ToInt32(s[4]);
FenyofaKesz = Convert.ToInt32(s[5]);
FenyofaEladott = Convert.ToInt32(s[6]);
NapiMunka.KeszultDb += HarangKesz + AngyalkaKesz + FenyofaKesz;
}
public int NapiBevetel()
{
return -(HarangEladott * 1000 + AngyalkaEladott * 1350 + FenyofaEladott * 1500);
}
}
public static class Data
{
public static List<NapiMunka> adatok = new List<NapiMunka>();
}
class Program
{
public static void AdatFeltolt()
{
FileStream fileStream = new FileStream("..\\diszek.txt", FileMode.Open, FileAccess.Read);
StreamReader streamReader = new StreamReader(fileStream);
string sor = streamReader.ReadLine();
while (sor != null)
{
NapiMunka melo = new NapiMunka(sor);
Data.adatok.Add(melo);
sor = streamReader.ReadLine();
}
streamReader.Close();
fileStream.Close();
}
public static void Feladat4()
{
Console.WriteLine($"4.feladat: Összesen {NapiMunka.KeszultDb} darab dísz készült");
}
public static bool NemKeszultDisz()
{
foreach (var item in Data.adatok)
{
if (item.AngyalkaKesz == 0 && item.FenyofaKesz == 0 && item.HarangKesz == 0)
{
return true;
}
}
return false;
}
public static void Feladat5()
{
if (NemKeszultDisz())
{
Console.WriteLine($"5.feladat: Volt olyan nap amikor egyetlen dísz sem készült.");
}
else
{
Console.WriteLine($"5.feladat: Nem volt olyan nap amikor egyetlen dísz sem készült.");
}
}
public static int Beker()
{
Console.Write("Adja meg a keresett napot [1 ... 40]: ");
string str = Console.ReadLine();
return int.Parse(str);
}
public static int ValidBeker()
{
while (true)
{
int num = Beker();
if (num < 41 && num > 0)
{
return num;
}
}
}
public static void Feladat6()
{
Console.WriteLine("6.feladat:");
int num = ValidBeker();
int harang = 0;
int angyal = 0;
int fenyo = 0;
for (int i = 0; i < num; i++)
{
angyal += Data.adatok[i].AngyalkaKesz + Data.adatok[i].AngyalkaEladott;
harang += Data.adatok[i].HarangEladott + Data.adatok[i].HarangKesz;
fenyo += Data.adatok[i].FenyofaKesz + Data.adatok[i].FenyofaEladott;
}
Console.WriteLine($"\tA(z) {num}. nap végén {harang} harang, {angyal} angyalka és {fenyo} fenyőfa maradt készleten.");
}
public static int AngyalEladottdb()
{
int cntr = 0;
foreach (var item in Data.adatok)
{
cntr += item.AngyalkaEladott;
}
return cntr;
}
public static int HaranglEladottdb()
{
int cntr = 0;
foreach (var item in Data.adatok)
{
cntr += item.HarangEladott;
}
return cntr;
}
public static int FenyoEladottdb()
{
int cntr = 0;
foreach (var item in Data.adatok)
{
cntr += item.FenyofaEladott;
}
return cntr;
}
public static void Feladat7()
{
int harang = HaranglEladottdb();
int fenyo = FenyoEladottdb();
int angyal = AngyalEladottdb();
int[] eladottak = { harang, fenyo, angyal };
Console.WriteLine($"7.feladat: Legtöbbet eladott dísz: {Math.Abs(eladottak.Min())} darab");
List<int> indexek = new List<int>();
for (int i = 0; i < eladottak.Length; i++)
{
if (eladottak[i] == eladottak.Min())
{
indexek.Add(i);
}
}
string[] megnevezesek = { "Harang", "Fenyőfa", "Angyalka" };
foreach (var item in indexek)
{
Console.WriteLine($"\t{ megnevezesek[item]}");
}
}
public static void Feladat8()
{
FileStream fileStream = new FileStream("bevetel.txt", FileMode.Create, FileAccess.Write);
StreamWriter streamWriter = new StreamWriter(fileStream);
int cntr = 0;
foreach (var item in Data.adatok)
{
if (item.NapiBevetel() >= 10000)
{
cntr++;
streamWriter.WriteLine($"{item.Nap};{item.NapiBevetel()}");
}
}
streamWriter.WriteLine($"{cntr} napon volt legalább 10000 Ft a bevétel.");
streamWriter.Close();
fileStream.Close();
}
static void Main(string[] args)
{
AdatFeltolt();
Feladat4();
Feladat5();
Feladat6();
Feladat7();
Feladat8();
}
}
}

@ -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("f8df1118-704f-41a4-a645-2fafc96eb37f")]
// 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")]

@ -0,0 +1,17 @@
6;13250
11;13550
14;10350
16;14850
17;12100
18;16750
23;13050
24;17250
28;16050
29;21100
30;20700
31;17600
33;11400
36;11700
38;11250
39;14750
16 napon volt legalább 10000 Ft a bevétel.

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]

@ -0,0 +1,7 @@
C:\Users\szabomarton\Desktop\C#\20240205\ConsoleApp1\bin\Debug\ConsoleApp1.exe.config
C:\Users\szabomarton\Desktop\C#\20240205\ConsoleApp1\bin\Debug\ConsoleApp1.exe
C:\Users\szabomarton\Desktop\C#\20240205\ConsoleApp1\bin\Debug\ConsoleApp1.pdb
C:\Users\szabomarton\Desktop\C#\20240205\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.AssemblyReference.cache
C:\Users\szabomarton\Desktop\C#\20240205\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.CoreCompileInputs.cache
C:\Users\szabomarton\Desktop\C#\20240205\ConsoleApp1\obj\Debug\ConsoleApp1.exe
C:\Users\szabomarton\Desktop\C#\20240205\ConsoleApp1\obj\Debug\ConsoleApp1.pdb

Binary file not shown.

@ -0,0 +1,30 @@
class NapiMunka
{
public static int KeszultDb { get; private set; }
public int Nap { get; private set; }
public int HarangKesz { get; private set; }
public int HarangEladott { get; private set; }
public int AngyalkaKesz { get; private set; }
public int AngyalkaEladott { get; private set; }
public int FenyofaKesz { get; private set; }
public int FenyofaEladott { get; private set; }
public NapiMunka(string sor)
{
string[] s = sor.Split(';');
Nap = Convert.ToInt32(s[0]);
HarangKesz = Convert.ToInt32(s[1]);
HarangEladott = Convert.ToInt32(s[2]);
AngyalkaKesz = Convert.ToInt32(s[3]);
AngyalkaEladott = Convert.ToInt32(s[4]);
FenyofaKesz = Convert.ToInt32(s[5]);
FenyofaEladott = Convert.ToInt32(s[6]);
NapiMunka.KeszultDb += HarangKesz + AngyalkaKesz + FenyofaKesz;
}
public int NapiBevetel()
{
return -(HarangEladott * 1000 + AngyalkaEladott * 1350 + FenyofaEladott * 1500);
}
}

@ -0,0 +1,40 @@
1;3;0;0;0;4;0
2;4;0;5;-2;1;0
3;1;-2;4;-3;0;0
4;0;0;3;-1;0;0
5;0;0;0;-2;3;-2
6;0;-5;6;-5;0;-1
7;3;0;3;0;1;-3
8;2;-3;0;0;3;0
9;5;0;6;-4;2;-3
10;0;-3;0;0;8;-4
11;2;-5;0;-3;1;-3
12;0;-1;0;-2;0;0
13;8;-3;0;-4;8;0
14;0;0;0;-1;3;-6
15;0;0;3;0;5;-4
16;4;-6;2;-1;6;-5
17;2;-4;8;-6;0;0
18;0;-1;4;-5;3;-6
19;0;0;1;-6;0;0
20;2;-3;0;0;2;-4
21;7;0;5;0;3;-3
22;3;0;0;0;4;-4
23;4;-6;5;-3;7;-2
24;0;0;0;-5;8;-7
25;0;0;6;-2;9;-4
26;0;0;0;-4;5;0
27;4;0;3;-2;0;0
28;0;-6;2;-3;2;-4
29;0;-4;4;-6;1;-6
30;0;0;7;-2;0;-12
31;0;-2;8;-6;0;-5
32;10;0;0;-3;4;-2
33;0;0;0;-4;3;-4
34;5;-8;0;0;4;0
35;2;0;9;-3;6;0
36;0;-3;0;-2;8;-4
37;0;0;6;-4;3;-2
38;0;0;8;-5;6;-3
39;3;-2;0;-5;5;-4
40;2;-4;4;-3;2;0
Loading…
Cancel
Save