I known that to compute series of number, we have to
puts #{(2+19)/3}
we have answer = 7
How to enter inputs from keyboard to do math, for variables as number 2
above, such as
puts #{(var +19)/3}
I tried puts var, printf #{var}, var=STDIN, STDOUT.puts var, all without
error but no answer!
It is working OK, if I have a given var with a value number:
var=2
puts #{(var +19)/3}
I will have answer = 7
Otherwise, if we put:
STDOUT.puts var
puts #{(var +19)/3}
error is: undefined local variable or method
Thank You
Can Le wrote:
I known that to compute series of number, we have to
puts #{(2+19)/3}
we have answer = 7
How to enter inputs from keyboard to do math, for variables as number 2
above, such as
puts #{(var +19)/3}
I tried puts var, printf #{var}, var=STDIN, STDOUT.puts var, all without
error but no answer!
It is working OK, if I have a given var with a value number:
var=2
puts #{(var +19)/3}
I will have answer = 7
Otherwise, if we put:
STDOUT.puts var
puts #{(var +19)/3}
error is: undefined local variable or method
Thank You
print “Enter a value?”
var = gets
puts (var.to_i+19)/3
try this, i hope it helps you.
Thank you