Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Bankanumer
- {
- class banki
- {
- static void Main(string[] args)
- {
- string numer = null;
- bool legal = false;
- while (legal != true)
- {
- Console.Write("Write the number(4-2-6): ");
- numer = Console.ReadLine();
- try
- {
- if (numer.Length == 14)
- {
- //Start for
- for (int counter = 0; counter < numer.Length; counter++)
- {
- //Check for numbers
- if (counter >= 0 && counter < 4 || counter == 5 || counter == 6 || counter >= 8 && counter <= 13)
- {
- if (char.IsDigit(numer[counter]))
- {
- legal = true;
- }
- else
- {
- legal = false;
- break;
- }
- }
- if (counter == 4 || counter == 7)
- {
- //Check for lines
- if (numer[counter] == '-')
- {
- legal = true;
- }
- else
- {
- legal = false;
- break;
- }
- }
- }//EndFor
- }//EndIf
- //Ef ekki 14 chars
- else
- {
- Console.WriteLine("Vitlaust magn af stöfum");
- }
- }//End Try
- catch
- {
- Console.WriteLine("Error");
- }
- }//End while
- if (legal)
- {
- Console.WriteLine("Correctly Written");
- }
- else
- {
- Console.WriteLine("Wrongly Written");
- }
- //Press any key to exit.
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement