-
Notifications
You must be signed in to change notification settings - Fork 1
/
Pregunta05.rb
40 lines (31 loc) · 890 Bytes
/
Pregunta05.rb
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
=begin
Desarrollar un subprograma que permita convertir soles a dólares y un subprograma que permita convertir de dólares
a soles tomando en cuenta un tipo de cambio de 2.55 soles por dolar
=end
TIPO_DE_CAMBIO = 2.55
def soles_a_dolares(monto)
return (monto / TIPO_DE_CAMBIO).round(2)
end
def dolares_a_soles(monto)
return (monto * TIPO_DE_CAMBIO).round(2)
end
#--- zona de test ----
def test_soles_a_dolares
print validate(100.00, soles_a_dolares(255.00))
print validate(1000.00, soles_a_dolares(2550.00))
end
def test_dolares_a_soles
print validate(255.00, dolares_a_soles(100.00))
print validate(2550.00, dolares_a_soles(1000.00))
end
def validate (expected, value)
expected == value ? "." : "F"
end
def test
puts "Test de prueba del programa"
puts "---------------------------"
test_soles_a_dolares
test_dolares_a_soles
puts " "
end
test