RealEstate1/RealEstate/Program.cs

35 lines
1.0 KiB
C#
Raw Normal View History

2024-04-04 10:17:48 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RealEstate
{
class Program
{
static void Main(string[] args)
{
2024-04-11 11:56:08 +00:00
List<Ad> hirdetesek = Ad.LoadFromCsv(@"..\..\realestates.csv");
double fszsumma = 0;
double darab = 0;
2024-04-04 10:17:48 +00:00
2024-04-11 11:56:08 +00:00
foreach (var item in hirdetesek)
{
if (item.Floors == 0)
{
fszsumma += item.Area;
darab++;
}
}
double atlag = fszsumma / darab;
Console.WriteLine($"6.feladat: A földszinti ingatlanok átlagos alapterülete: {atlag:F2} m2.");
//6.feladat - Lambda
//double atlag2 = hirdetesek.Average(h => h.Area);
double atlag2 = hirdetesek.Where(h => h.Floors == 0).Average(h => h.Area);
Console.WriteLine($"6.feladat/2: A földszinti ingatlanok átlagos alapterülete: {atlag2:F2} m2.");
2024-04-04 10:17:48 +00:00
}
}
}