/* Veidoja: Tomass Dučkens
Grupa: 110
PR7
Izmantotais compiler:https://www.onlinegdb.com/online_csharp_compiler
*/
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
static void Main()
{
static void AttalumaKalkulators()
{
	Console.Clear();
	Console.Write("Ievadiet pirma punkta koordinatas: ");
	string[] p1 = Console.ReadLine().Split(' ');

	double a1 = Convert.ToDouble(p1[0]);
	double b1 = Convert.ToDouble(p1[1]);

	Console.Write("Ievadiet otra punkta koordinatas: ");
	string[] p2 = Console.ReadLine().Split(' ');

	double a2 = Convert.ToDouble(p2[0]);
	double b2 = Convert.ToDouble(p2[1]);

	double dx = Math.Pow(a2 - a1, 2);
	double dy = Math.Pow(b2 - b1, 2);
	double attalums = Math.Round(Math.Sqrt(dx + dy), 2);

	Console.Clear();
	Console.WriteLine($"Attalums starp punktiem: {attalums}");

	Console.WriteLine("Nospiediet Enter lai parverst gradus radianos!");
	while (Console.ReadKey().Key != ConsoleKey.Enter) { }
	GradusRadians();
}

static void GradusRadians()
{
	Console.Clear();
	Console.Write("Ievadiet lenki grdos: ");
	double deg = Convert.ToDouble(Console.ReadLine());
	double rad = Math.Round(deg * (Math.PI / 180), 2);

	Console.WriteLine($"{deg}B0 = {rad} rad");
	Console.WriteLine("Nospiediet Enter lai atgrieztos izvelne!");
	while (Console.ReadKey().Key != ConsoleKey.Enter) { }
	Main();

	{
		if (glabatuve[i, j] == kods)
		{
			rinda = i;
			kolonna = j;
			atrasts = true;
			break;
		}
	}
	if (atrasts) break;
}

if (atrasts) Console.WriteLine($"Prece ir {rinda + 1}. eja, {kolonna + 1}. plaukta.");
else Console.WriteLine("Prece nav atrasta.");

Console.WriteLine("Nospiediet Enter lai aprekinatu tuksos plauktus!");
while (Console.ReadKey().Key != ConsoleKey.Enter) { }
SaskaititTuksos(glabatuve);
}

static void SaskaititTuksos(string[,] glabatuve)
{
	int tuksie = 0;
	foreach (var v in glabatuve)
		if (string.IsNullOrEmpty(v)) tuksie++;

	Console.Clear();
	Console.WriteLine($"Noliktava ir {tuksie} tuks plaukti.");

	Console.WriteLine("Nospiediet Enter lai atgrieztos izvelne!");
	while (Console.ReadKey().Key != ConsoleKey.Enter) { }
	Main();
}

static void IevaditIzmaksas(List<double> izmaksas)
{
	bool turpinat = true;

	do
	{
		Console.Clear();
		Console.WriteLine("Ievadiet izdevumu!");
		Console.WriteLine("Ievadiet 'beigt' lai turpinatu!");
		string ievade = Console.ReadLine();
		double summa;

		if (Double.TryParse(ievade, out summa))
		{
			izmaksas.Add(summa);
		}
		else
		{
			if (ievade == "" || ievade == "beigt") turpinat = false;
		}
	} while (turpinat);

	Console.Clear();
	foreach (double s in izmaksas) Console.WriteLine(s);

	Console.WriteLine("Nospiediet Enter lai filtretu izmaksas!");
	while (Console.ReadKey().Key != ConsoleKey.Enter) { }
	FiltretsIzmaksas(izmaksas);
}

static void FiltretsIzmaksas(List<double> izmaksas)
{
	List<double> filtreti = izmaksas.Where(v => v > 35.00).ToList();
	Console.Clear();
	foreach (double f in filtreti) Console.WriteLine(f);

	Console.WriteLine("Nospiediet Enter lai aprekinatu mainibu!");
	while (Console.ReadKey().Key != ConsoleKey.Enter) { }
	NoteiktMainibu(filtreti);
}

static void NoteiktMainibu(List<double> filtreti)
{
	double minV = filtreti.Min();
	double maxV = filtreti.Max();
	double starpiba = maxV - minV;

	Console.Clear();
	Console.WriteLine($"Izdevumu mainiba ir {starpiba}");

	Console.WriteLine("Nospiediet Enter lai atgrieztos izvelne!");
	while (Console.ReadKey().Key != ConsoleKey.Enter) { }
	Main();
}
}
}
}