-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
69 lines (59 loc) · 2.4 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Linq;
namespace exercises_csharp {
class Program {
static void Main (string[] args) {
IDictionary<int, string> Listado = new Dictionary<int, string> ();
//Create a Instance of General Class
Program ExercisesToRun = new Program ();
Listado.Add (1, "Inverter Two position numbers");
Listado.Add (2, "Inverter Three position numbers");
Console.WriteLine ("Menu: List of Exercises");
foreach (KeyValuePair<int, string> s in Listado) {
Console.WriteLine ("ID Example: {0} Description: {1}", s.Key, s.Value);
}
Console.WriteLine ("Select number of exercises, please");
var NumberExercise = Console.ReadLine ();
switch (NumberExercise) {
case "1":
ExercisesToRun.InverterNumber2Positions_1 ();
break;
case "2":
ExercisesToRun.InverterNumber3Positions_2 ();
break;
}
}
//1) Return a inverter number of two-digits number
void InverterNumber2Positions_1 () {
int NUM, AUX, DEC, UNI;
string linea;
Console.WriteLine ("Enter two-digits number");
linea = Console.ReadLine ();
NUM = int.Parse (linea);
DEC = NUM / 10;
UNI = NUM % 10;
AUX = (UNI * 10) + DEC;
Console.WriteLine ("Inverter number is: " + AUX);
Console.WriteLine ("Press to end");
Console.ReadLine ();
}
//2) Return a inverter number of three-digits number
void InverterNumber3Positions_2 () {
int NUM, AUX, DEC, UNI, CEN;
string linea;
Console.WriteLine ("Enter three-digits number");
linea = Console.ReadLine ();
NUM = int.Parse (linea);
CEN = NUM / 100;
NUM = NUM % 100;
DEC = NUM / 10;
UNI = NUM % 10;
AUX = (UNI * 100) + (DEC * 10) + CEN;
Console.WriteLine ($"NUM: {NUM}, CEN: {CEN}, DEC: {DEC}, UNI: {UNI}");
Console.WriteLine ("Inverter number is: " + AUX);
Console.WriteLine ("Press to end");
Console.ReadLine ();
}
}
}