|
|
|
using System;
|
|
|
|
|
|
|
|
namespace ConsoleApplication9
|
|
|
|
{
|
|
|
|
class BanknotePruefen
|
|
|
|
{
|
|
|
|
// Helferfunktion zur Berechnung der Quersumme
|
|
|
|
public static int QuerSumme(int zahl)
|
|
|
|
{
|
|
|
|
int querSumme = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
querSumme += zahl % 10;
|
|
|
|
zahl /= 10;
|
|
|
|
} while (zahl > 0);
|
|
|
|
|
|
|
|
return querSumme;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int pruefeSeriennummer(string seriennummer)
|
|
|
|
{
|
|
|
|
// Buchstaben durch Zahl ersetzen (Grundlage: ASCII zuordnung)
|
|
|
|
char[] seriennummerChar = seriennummer.ToCharArray(0, 12);
|
|
|
|
|
|
|
|
int positionszahl = (int)seriennummerChar[0] - 64;
|
|
|
|
int q1 = QuerSumme(positionszahl);
|
|
|
|
int q2 = 0;
|
|
|
|
for (int i = 1; i <= 10; i++) {
|
|
|
|
Console.WriteLine(Convert.ToString(q2 + "\r\n"));
|
|
|
|
q2 += ((int)seriennummerChar[i]-48);
|
|
|
|
}
|
|
|
|
int quersumme = (int)q1 + (int)q2;
|
|
|
|
|
|
|
|
int subtrahend = (quersumme % 9);
|
|
|
|
int result = 8 - subtrahend;
|
|
|
|
if (result == 0) result = 9;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Program
|
|
|
|
{
|
|
|
|
static void Main(string[] args)
|
|
|
|
{
|
|
|
|
BanknotePruefen bp = new BanknotePruefen();
|
|
|
|
|
|
|
|
string seriennummer = Console.ReadLine();
|
|
|
|
int erg = bp.pruefeSeriennummer(seriennummer);
|
|
|
|
|
|
|
|
Console.WriteLine(erg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|