I recently discussed in this group the basic starting of a project. I
am getting a little confused at passing a variable between a
calculation.

I am learning so can take some feedback and criticism the part of the
code I am referring to is Scenario 1. I am trying to ensure that the
calcualted value of x is never greater than 1.0. So I am aiming to
determine the value of x for the second calc if the result of the
first calculation produces a valid result.

r = 5.0
p = 10.0
per = 190.0
max_x = 0.8

x = 0.05
const = r*100 # simplified without X
x += 0.05 while (x*const < per) && (x <= max_x)
puts x <= max_x ? "#{x*100.0}%" : "no answer"

Bank = $500.00 # later to be a running total calculated

def ROIcalc
const = r*100 # simplified without X
x += 0.05 while (x*const < per) && (x <= max_x)
puts x <= max_x ? "#{x*100.0}%" : "no answer"
end

def pool
if Bank > 200 then Bank * 0.05
Else $10.00
end

# here in case I need it
def round
  return floor(self+0.5) if self > 0.0
  return ceil(self-0.5)  if self < 0.0
  return 0.0
end

# Scenario 1
# simple 2 option scenario where the max allocation is to option a
a = ROIcalc(per = 190, max_x = 0.8, puts "What ratio of return do you
expect?" r = gets.chomp, pool)
	If for x in a < 0.6 then x in a = 0.6 & for x in b = 0.4
		elseif x > 0.8 then puts " This option is invalid you exceed
allocation" # take user somewhere
		# Take user to choose another option
		else for x in b = 1.0 - x
	b = ROIcalc(per = 200, max_x = 0.4, r = 12.00, pool)