SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | using System.Collections.Generic; | |
3 | using System.Linq; | |
4 | using System.Text; | |
5 | ||
6 | namespace Bankanumer | |
7 | { | |
8 | class banki | |
9 | { | |
10 | static void Main(string[] args) | |
11 | { | |
12 | string numer = null; | |
13 | bool legal = false; | |
14 | while (legal != true) | |
15 | { | |
16 | - | Console.Write("SWrite the number (4-2-6): "); |
16 | + | Console.Write("Write the number(4-2-6): "); |
17 | numer = Console.ReadLine(); | |
18 | try | |
19 | { | |
20 | if (numer.Length == 14) | |
21 | { | |
22 | //Start for | |
23 | for (int counter = 0; counter < numer.Length; counter++) | |
24 | { | |
25 | //Check for numbers | |
26 | - | if (counter >= 0 && counter < 4|| counter == 5 || counter == 6 || counter >= 8 && counter <= 13) |
26 | + | if (counter >= 0 && counter < 4 || counter == 5 || counter == 6 || counter >= 8 && counter <= 13) |
27 | { | |
28 | if (char.IsDigit(numer[counter])) | |
29 | { | |
30 | legal = true; | |
31 | } | |
32 | else | |
33 | - | else |
33 | + | |
34 | legal = false; | |
35 | - | legal = false; |
35 | + | |
36 | - | break; |
36 | + | |
37 | } | |
38 | if (counter == 4 || counter == 7) | |
39 | { | |
40 | //Check for lines | |
41 | if (numer[counter] == '-') | |
42 | { | |
43 | legal = true; | |
44 | } | |
45 | else | |
46 | { | |
47 | legal = false; | |
48 | break; | |
49 | } | |
50 | } | |
51 | }//EndFor | |
52 | }//EndIf | |
53 | - | //if not 14 chars |
53 | + | //Ef ekki 14 chars |
54 | else | |
55 | { | |
56 | - | Console.WriteLine("Wrong amount of letters"); |
56 | + | Console.WriteLine("Vitlaust magn af stöfum"); |
57 | ||
58 | } | |
59 | ||
60 | }//End Try | |
61 | catch | |
62 | { | |
63 | - | Console.WriteLine("Error!"); |
63 | + | Console.WriteLine("Error"); |
64 | } | |
65 | }//End while | |
66 | if (legal) | |
67 | { | |
68 | Console.WriteLine("Correctly Written"); | |
69 | } | |
70 | else | |
71 | { | |
72 | Console.WriteLine("Wrongly Written"); | |
73 | } | |
74 | //Press any key to exit. | |
75 | Console.ReadKey(); | |
76 | } | |
77 | } | |
78 | } |