Skip to content

Instantly share code, notes, and snippets.

@abimaelmartell
Created August 12, 2014 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abimaelmartell/ae90d2f357371be375f5 to your computer and use it in GitHub Desktop.
Save abimaelmartell/ae90d2f357371be375f5 to your computer and use it in GitHub Desktop.
def calcularTotal(monto,tipoCliente,tiempo)
total = monto.to_f
if tipoCliente == "A"
tasa_mensual = 0.04
elsif tipoCliente == "B"
tasa_mensual = 0.09
else
tasa_mensual = 0.12
end
i = 0
while i < tiempo do
interes = total * tasa_mensual
total += interes
i += 1
end
return total.round(2)
end
#--- zona de test ----
def test_calcularTotal
print validate(112.49, calcularTotal(100,"A",3))
print validate(1677.10, calcularTotal(1000,"B",6))
print validate(8181.55, calcularTotal(2100,"C",12))
end
def validate (expected, value)
expected == value ? "." : "F"
end
def test
puts "Test de prueba del programa"
puts "---------------------------"
test_calcularTotal
puts " "
end
test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment