Oplossingen H8 Week 2
ArrayViewer
static void VisualiseerArray(int[] array)
{
for (int i = 0; i < array.Length-1; i++)
{
Console.Write($"{array[i]}\t");
}
Console.WriteLine($"{array[array.Length-1]}");
}Parkeergarage
static void Main()
{
Console.WriteLine("Geef aantal auto's in:");
int aantal = Convert.ToInt32(Console.ReadLine());
double[] duur = new double[aantal];
for (int i = 0; i < duur.Length; i++)
{
Console.WriteLine($"Geef parkeertijd auto {i + 1} in (uren)");
duur[i] = Convert.ToDouble(Console.ReadLine());
}
ToonResultaat(duur);
}
static void ToonResultaat(double[] duur)
{
double somDuur = 0;
double somKost = 0;
Console.WriteLine("Auto\tDuur\tKost");
for (int i = 0; i < duur.Length; i++)
{
double kost = BerekenKosten(duur[i]);
somKost += kost;
somDuur += duur[i];
Console.WriteLine($"{i+1}\t{duur[i]}\t{kost}");
}
Console.WriteLine($"Totaal\t{somDuur}\t{somKost}");
}
static double BerekenKosten(double duur)
{
double kost = 2;
if (duur > 3)
{
double extra = Math.Ceiling(duur - 3);
kost += (extra * 0.5);
}
if (kost > 10)
{
kost = 10;
}
return kost;
}Caesar Encryptie
Determinant
Robot simulator
Last updated
Was this helpful?