Сделать код на сишарпе Элементом списка является информация о заводе, включающая наименование, ФИО директора, количество видов выпускаемых товаров (11000), средний годовой доход, млн. руб. (0,11000,0 найти завод с максимальной доходностью
namespace MaxRevenue { class Plant { public string Name { get; set; } public string Director { get; set; } public int NumberOfProducts { get; set; } public double AnnualIncome { get; set; } }
class Program { static void Main(string[] args) { Plant[] plants = new Plant[3]; plants[0] = new Plant { Name = "Plant1", Director = "Director1", NumberOfProducts = 1000, AnnualIncome = 1.2 }; plants[1] = new Plant { Name = "Plant2", Director = "Director2", NumberOfProducts = 8000, AnnualIncome = 2.5 }; plants[2] = new Plant { Name = "Plant3", Director = "Director3", NumberOfProducts = 5000, AnnualIncome = 3.8 }; double maxIncome = 0; Plant maxRevenuePlant = new Plant(); foreach (Plant plant in plants) { if (plant.AnnualIncome > maxIncome) { maxIncome = plant.AnnualIncome; maxRevenuePlant = plant; } } Console.WriteLine($"The plant with the maximum revenue is {maxRevenuePlant.Name} with an annual income of {maxIncome} million rubles."); } }
using System;
namespace MaxRevenue
class Program{
class Plant
{
public string Name { get; set; }
public string Director { get; set; }
public int NumberOfProducts { get; set; }
public double AnnualIncome { get; set; }
}
{
static void Main(string[] args)
{
Plant[] plants = new Plant[3];
plants[0] = new Plant { Name = "Plant1", Director = "Director1", NumberOfProducts = 1000, AnnualIncome = 1.2 };
plants[1] = new Plant { Name = "Plant2", Director = "Director2", NumberOfProducts = 8000, AnnualIncome = 2.5 };
plants[2] = new Plant { Name = "Plant3", Director = "Director3", NumberOfProducts = 5000, AnnualIncome = 3.8 };
double maxIncome = 0;
Plant maxRevenuePlant = new Plant();
foreach (Plant plant in plants)
{
if (plant.AnnualIncome > maxIncome)
{
maxIncome = plant.AnnualIncome;
maxRevenuePlant = plant;
}
}
Console.WriteLine($"The plant with the maximum revenue is {maxRevenuePlant.Name} with an annual income of {maxIncome} million rubles.");
}
}
}