-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.java
More file actions
124 lines (107 loc) · 4.84 KB
/
Copy pathProgram.java
File metadata and controls
124 lines (107 loc) · 4.84 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import Exceptions.InvalidOptionException;
import Services.Currencies;
import Services.CurrencyConverter;
import Services.ICurrencyConverter;
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Currencies from = Currencies.AmericanDolar;
int scFrom = 0;
Currencies to = Currencies.MexicanPeso;
int scTo = 0;
float amount = 0;
float resultAmount = 0;
var sc = new Scanner(System.in);
ICurrencyConverter service = new CurrencyConverter();
java.lang.String logo = """
___ ___ ___ ________ ________ ___ ___\s
|\\ \\|\\ \\|\\ \\|\\ ___ \\|\\ __ \\ |\\ \\ / /|
\\ \\ \\ \\ \\\\\\ \\ \\ \\\\ \\ \\ \\ \\|\\ \\ \\ \\ \\/ / /
__ \\ \\ \\ \\ \\\\\\ \\ \\ \\\\ \\ \\ \\ \\\\\\ \\ \\ \\ / /\s
|\\ \\\\_\\ \\ \\ \\\\\\ \\ \\ \\\\ \\ \\ \\ \\\\\\ \\ / \\/ \s
\\ \\________\\ \\_______\\ \\__\\\\ \\__\\ \\_______\\/ /\\ \\ \s
\\|________|\\|_______|\\|__| \\|__|\\|_______/__/ /\\ __\\\s
|__|/ \\|__|\s
\s
\s \s
Made with love by Dtopiast \s \s """;
System.out.println(logo);
System.out.println("Conversor de divisas\s" );
System.out.println("""
Selecciona una opcion valida:
(0) Dolar Americano
(1) Peso Mexicano
(2) Peso Argentino
(3) peso colombiano
(4) Real brasile:no
(5) Euro
(6) salir
""");
do {
try {
System.out.println("Coloque la moneda de origen: ");
scFrom = sc.nextInt();
switch (scFrom) {
case 0 -> {
from = Currencies.AmericanDolar;
}
case 1 -> {
from = Currencies.MexicanPeso;
}
case 2 -> {
from = Currencies.ArgentinePeso;
}
case 3 -> {
from = Currencies.ColombianPeso;
}
case 4 -> {
from = Currencies.RealBresileño;
}
case 5 -> {
from = Currencies.Euro;
}
case 6 -> {
System.exit(0);
}
default -> throw new InvalidOptionException();
}
System.out.println("Coloque la moneda a convertir: ");
scTo = sc.nextInt();
switch (scTo) {
case 0 -> {
to = Currencies.AmericanDolar;
}
case 1 -> {
to = Currencies.MexicanPeso;
}
case 2 -> {
to = Currencies.ArgentinePeso;
}
case 3 -> {
to = Currencies.ColombianPeso;
}
case 4 -> {
to = Currencies.RealBresileño;
}
case 5 -> {
to = Currencies.Euro;
}
case 6 -> {
System.exit(0);
}
default -> throw new InvalidOptionException();
}
System.out.println("Coloque el monto: ");
var scAmount = sc.next().replace(",", ".");
amount = Float.parseFloat(scAmount);
resultAmount = service.getConversion(from,to,amount);
System.out.printf("El resultado es : %.2f%n \s", resultAmount);
}
catch (Exception ex)
{
System.out.println("Opcion invalida, intentelo otra vez revisando el si el valor es correcto.");
scFrom = 0;
}
} while(scFrom !=6);
}
}