Aykon

IBAN

Mar 7th, 2023
1,121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. //Program.cs
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace IBAN
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Console.WriteLine("Geef een volledig nummer zonder spaties");
  15.             string invoer = Console.ReadLine();
  16.             bool geldig;
  17.  
  18.             if (invoer.Length == 16)
  19.             {
  20.                 string land = invoer.Substring(0,2);
  21.                 long rekening = Convert.ToInt64(invoer.Substring(4, 10));
  22.                 int controle = Convert.ToInt32(invoer.Substring(14, 2));
  23.  
  24.                 if (land != "BE")
  25.                 {
  26.                     geldig = false;
  27.                 }
  28.                 else
  29.                 {
  30.                     if ((rekening%97)!= controle)
  31.                     {
  32.                         geldig = false;
  33.                     }
  34.                     else
  35.                     {
  36.                         geldig = true;
  37.                     }
  38.                 }
  39.             }
  40.             else
  41.             {
  42.                 geldig = false;
  43.             }
  44.             Console.WriteLine();
  45.  
  46.             string melding = "";
  47.             if (!geldig )
  48.             {
  49.                 melding = "g";
  50.                 Console.ForegroundColor = ConsoleColor.Red;
  51.             }
  52.             else
  53.             {
  54.                 Console.ForegroundColor = ConsoleColor.Green;
  55.             }
  56.             Console.WriteLine("Dit is {0}een geldig IBAN nummer", melding);
  57.             Console.ReadLine();
  58.  
  59.  
  60.         }
  61.     }
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment