-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMissão_4.rb
More file actions
64 lines (53 loc) · 1.28 KB
/
Missão_4.rb
File metadata and controls
64 lines (53 loc) · 1.28 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
def munito
20.times do
print "-="
end
puts "-"
print "\n"
end
loop do
cont = 1
operacoes = ["1", "2", "3", "4"]
munito
puts ">> Calculadora"
munito
puts ">> Selecione a opção desejada:\n\n"
puts "1: Somar (+)"
puts "2: Subtrair (-)"
puts "3: Multiplicar (x)"
puts "4: Dividir (/)"
puts "0: para sair"
print "\n>> Digite a opção: "
operacao = gets.chomp.strip
munito
if operacoes.include?("#{operacao}") == true
print "Digite o 1° numero para a operação: "
num1 = gets.chomp.strip.to_i
print "Digite o 2° numero para a operação: "
num2 = gets.chomp.strip.to_i
case operacao
when "1"
d = "+"
r = num1 + num2
when "2"
d = "-"
r = num1 - num2
when "3"
d = "*"
r = num1 * num2
when "4"
d = "/"
r = num1 / num2
end
puts "\n>> Resposta: #{num1} #{d} #{num2} = #{r}"
munito
elsif operacao == "0"
print "Muito obrigado por utilizar"
break
else
puts "Digitou errado, tente novamente:"
end
print "Digite Enter para continuar: "
confir = gets
system "cls"
end