Advertisement
Aykon

IbanLagen

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