-
-
Save abimaelmartell/ae90d2f357371be375f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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