-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetodos.rb
More file actions
53 lines (48 loc) · 797 Bytes
/
Copy pathmetodos.rb
File metadata and controls
53 lines (48 loc) · 797 Bytes
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
#Creando calculadora para entender el funcionamiento
=begin
# Entendiendo el significado de como viaja el valor
def suma(a,b)
puts a+b
puts a+b
a+b
end
suma_var = suma(4,5)
puts '*'
puts suma_var
=end
def saludo(variable)
puts "hola #{variable}"
end
saludo("Variable")
def suma(a,b)
a+b
end
def resta(a,b)
a-b
end
def mult(a,b)
a*b
end
def divide(a,b)
a/b
end
def exp(a,b)
a**b
end
puts (".:Welcome a la calcuradora.:")
print ('Ingresa el primer numero=>')
num1 = gets.chomp.to_i
print ('Ingresa el segundo numero=>')
num2 = gets.chomp.to_i
print("[1]. Sum\n [2].rest\n [3].div\n [#].Salir\n")
datos = gets.chomp.to_i
puts case datos
when 1
suma(num1,num2)
when 2
rest(num1,num2)
when 3
div(num1,num2)
else
puts "Saliendo de la calculadora"
end