add Programmyday form github

This commit is contained in:
Ruben Kallinich
2024-07-25 15:47:46 +02:00
parent 09c8eab938
commit 7362c3d7ce
132 changed files with 3669 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IBANNummerPrüfen
{
public class IbanPrüfung
{
// Richtiges IBAN Format: DE68 2105 0170 0012 3456 78
//private string? IBAN;
private string? ibanCleared;
private string? ibanSwapped;
private string? sum;
private string? iban;
public void SetIbanPrüfungEntgegennehmen()
{
Console.Write("Bitte geben Sie ihre IBAN-Nummer ein: ");
this.iban = Console.ReadLine();
Console.WriteLine(IBANPrüfung());
}
/// <summary>
/// Bestimmt ob die Checksumme einer IBAN gültig ist
/// </summary>
/// <param name="iban">Der zu prüfende IBAN (z.B: "DE68 2105 0170 0012 3456 78")</param>
/// <returns><c>True</c>, wenn <paramref name="value"/> gültig ist. Andernfalls <c>False</c>.</returns>
public bool IBANPrüfung()
{
if (this.iban != null)
{
this.ibanCleared = this.iban.ToUpper().Replace(" ", "").Replace("-", "").Replace(".", "");
//Console.WriteLine(ibanCleared);
this.ibanSwapped = ibanCleared.Substring(4) + ibanCleared.Substring(0, 4);
//Console.WriteLine(ibanSwapped);
this.sum = ibanSwapped.Aggregate("", (current, c) => current + (char.IsLetter(c) ? (c - 55).ToString() : c.ToString()));
//Console.WriteLine(sum);
//this.sum = ibanCleared.Aggregate("", (current, c) => current + (char.IsLetter(c) ? (c - 55).ToString() : c.ToString()));
var d = decimal.Parse(sum);
return ((d % 97) == 1);
}
return false;
}
}
}