Need help, i'm a beginner

as i’m a beginner I wanted to make a script that counts results with user’s inputed numbers, using 2 formulas, but running this script makes it difficult to read the results, so I need help :

puts “formula (Vteor = 0.10472nrk)/it - lai atrastu atrumu m/s UN Vteor = 0.377nrk)/it - lai atrastu atrumu km/h”

puts “Ievadi savu rk (ritena kinematiskais radiuss)”
r = gets.chomp.to_f
puts "Ievadi savu it1 "
i1 = gets.chomp.to_f
puts "Ievadi savu it2 "
i2 = gets.chomp.to_f
puts “Ievadi savu it3”
i3 = gets.chomp.to_f
puts "Ievadi savu it4 "
i4 = gets.chomp.to_f
puts "Ievadi savu it5 "
i5 = gets.chomp.to_f
puts "Ievadi savu it6 "
i6 = gets.chomp.to_f

a = 0.10472.to_f #lai atrastu m/s
b = 0.377.to_f #lai atrastu km/h
w = 0.to_f #
s = 0.to_f #

``````  while w <= 7999 #
w += 500
s += 500

# 1p
``````

res1 = awr/i1 # rezultats m/s
res11 = bwr/i1 # rezultats km/h
#2p
res2 = awr/i2 # rezultats m/s
res22 = bwr/i2 # rezultats km/h
#3p
res3 = awr/i3 # rezultats m/s
res33 = bwr/i3 # rezultats km/h
#4p
res4 = awr/i4 # rezultats m/s
res44 = bwr/i4 # rezultats km/h
#5p
res5 = awr/i5 # rezultats m/s
res55 = bwr/i5 # rezultats km/h
#6p
res6 = awr/i6 # rezultats m/s
res66 = bwr/i6 # rezultats km/h

puts “VteorI1 = #{sprintf(’%.5f’, res1)} M/S” + " VteorI1 = #{sprintf(’%.5f’, res11)} KM/h pie #{s} apgr/min" # sprintf%5f - 5 cipari pec komata (f - float, 5 - amount)

puts “VteorI2 = #{sprintf(’%.5f’, res2)} M/S” + " VteorI2 = #{sprintf(’%.5f’, res22)} KM/h pie #{s} apgr/min" #2p

puts “VteorI3 = #{sprintf(’%.5f’, res3)} M/S” + " VteorI3 = #{sprintf(’%.5f’, res33)} KM/h pie #{s} apgr/min" #3p

puts “VteorI4 = #{sprintf(’%.5f’, res4)} M/S” + " VteorI4 = #{sprintf(’%.5f’, res44)} KM/h pie #{s} apgr/min" #4p

puts “VteorI5 = #{sprintf(’%.5f’, res5)} M/S” + " VteorI5 = #{sprintf(’%.5f’, res55)} KM/h pie #{s} apgr/min" #5p

puts “VteorI6 = #{sprintf(’%.5f’, res6)} M/S” + " VteorI6 = #{sprintf(’%.5f’, res66)} KM/h pie #{s} apgr/min" #6p

``````  end
``````

so when I run the script I see and inputing numbers it gives me the results :

VteorI1 = 2.24400 M/S VteorI1 = 8.07857 KM/h pie 500.0 apgr/min
VteorI2 = 2.61800 M/S VteorI2 = 9.42500 KM/h pie 500.0 apgr/min
VteorI3 = 3.14160 M/S VteorI3 = 11.31000 KM/h pie 500.0 apgr/min
VteorI4 = 3.92700 M/S VteorI4 = 14.13750 KM/h pie 500.0 apgr/min
VteorI5 = 5.23600 M/S VteorI5 = 18.85000 KM/h pie 500.0 apgr/min
VteorI6 = 7.85400 M/S VteorI6 = 28.27500 KM/h pie 500.0 apgr/min
VteorI1 = 4.48800 M/S VteorI1 = 16.15714 KM/h pie 1000.0 apgr/min
VteorI2 = 5.23600 M/S VteorI2 = 18.85000 KM/h pie 1000.0 apgr/min
VteorI3 = 6.28320 M/S VteorI3 = 22.62000 KM/h pie 1000.0 apgr/min
VteorI4 = 7.85400 M/S VteorI4 = 28.27500 KM/h pie 1000.0 apgr/min
VteorI5 = 10.47200 M/S VteorI5 = 37.70000 KM/h pie 1000.0 apgr/min
VteorI6 = 15.70800 M/S VteorI6 = 56.55000 KM/h pie 1000.0 apgr/min
VteorI1 = 6.73200 M/S VteorI1 = 24.23571 KM/h pie 1500.0 apgr/min
VteorI2 = 7.85400 M/S VteorI2 = 28.27500 KM/h pie 1500.0 apgr/min
VteorI3 = 9.42480 M/S VteorI3 = 33.93000 KM/h pie 1500.0 apgr/min
VteorI4 = 11.78100 M/S VteorI4 = 42.41250 KM/h pie 1500.0 apgr/min
VteorI5 = 15.70800 M/S VteorI5 = 56.55000 KM/h pie 1500.0 apgr/min
VteorI6 = 23.56200 M/S VteorI6 = 84.82500 KM/h pie 1500.0 apgr/min
VteorI1 = 8.97600 M/S VteorI1 = 32.31429 KM/h pie 2000.0 apgr/min
VteorI2 = 10.47200 M/S VteorI2 = 37.70000 KM/h pie 2000.0 apgr/min
VteorI3 = 12.56640 M/S VteorI3 = 45.24000 KM/h pie 2000.0 apgr/min
VteorI4 = 15.70800 M/S VteorI4 = 56.55000 KM/h pie 2000.0 apgr/min
VteorI5 = 20.94400 M/S VteorI5 = 75.40000 KM/h pie 2000.0 apgr/min
VteorI6 = 31.41600 M/S VteorI6 = 113.10000 KM/h pie 2000.0 apgr/min
VteorI1 = 11.22000 M/S VteorI1 = 40.39286 KM/h pie 2500.0 apgr/min
VteorI2 = 13.09000 M/S VteorI2 = 47.12500 KM/h pie 2500.0 apgr/min
VteorI3 = 15.70800 M/S VteorI3 = 56.55000 KM/h pie 2500.0 apgr/min
VteorI4 = 19.63500 M/S VteorI4 = 70.68750 KM/h pie 2500.0 apgr/min
VteorI5 = 26.18000 M/S VteorI5 = 94.25000 KM/h pie 2500.0 apgr/min
VteorI6 = 39.27000 M/S VteorI6 = 141.37500 KM/h pie 2500.0 apgr/min
VteorI1 = 13.46400 M/S VteorI1 = 48.47143 KM/h pie 3000.0 apgr/min
VteorI2 = 15.70800 M/S VteorI2 = 56.55000 KM/h pie 3000.0 apgr/min
VteorI3 = 18.84960 M/S VteorI3 = 67.86000 KM/h pie 3000.0 apgr/min
VteorI4 = 23.56200 M/S VteorI4 = 84.82500 KM/h pie 3000.0 apgr/min
VteorI5 = 31.41600 M/S VteorI5 = 113.10000 KM/h pie 3000.0 apgr/min
VteorI6 = 47.12400 M/S VteorI6 = 169.65000 KM/h pie 3000.0 apgr/min
VteorI1 = 15.70800 M/S VteorI1 = 56.55000 KM/h pie 3500.0 apgr/min
VteorI2 = 18.32600 M/S VteorI2 = 65.97500 KM/h pie 3500.0 apgr/min
VteorI3 = 21.99120 M/S VteorI3 = 79.17000 KM/h pie 3500.0 apgr/min
VteorI4 = 27.48900 M/S VteorI4 = 98.96250 KM/h pie 3500.0 apgr/min
VteorI5 = 36.65200 M/S VteorI5 = 131.95000 KM/h pie 3500.0 apgr/min
VteorI6 = 54.97800 M/S VteorI6 = 197.92500 KM/h pie 3500.0 apgr/min
VteorI1 = 17.95200 M/S VteorI1 = 64.62857 KM/h pie 4000.0 apgr/min
VteorI2 = 20.94400 M/S VteorI2 = 75.40000 KM/h pie 4000.0 apgr/min
VteorI3 = 25.13280 M/S VteorI3 = 90.48000 KM/h pie 4000.0 apgr/min
VteorI4 = 31.41600 M/S VteorI4 = 113.10000 KM/h pie 4000.0 apgr/min
VteorI5 = 41.88800 M/S VteorI5 = 150.80000 KM/h pie 4000.0 apgr/min
VteorI6 = 62.83200 M/S VteorI6 = 226.20000 KM/h pie 4000.0 apgr/min
VteorI1 = 20.19600 M/S VteorI1 = 72.70714 KM/h pie 4500.0 apgr/min
VteorI2 = 23.56200 M/S VteorI2 = 84.82500 KM/h pie 4500.0 apgr/min
VteorI3 = 28.27440 M/S VteorI3 = 101.79000 KM/h pie 4500.0 apgr/min
VteorI4 = 35.34300 M/S VteorI4 = 127.23750 KM/h pie 4500.0 apgr/min
VteorI5 = 47.12400 M/S VteorI5 = 169.65000 KM/h pie 4500.0 apgr/min
VteorI6 = 70.68600 M/S VteorI6 = 254.47500 KM/h pie 4500.0 apgr/min
VteorI1 = 22.44000 M/S VteorI1 = 80.78571 KM/h pie 5000.0 apgr/min
VteorI2 = 26.18000 M/S VteorI2 = 94.25000 KM/h pie 5000.0 apgr/min
VteorI3 = 31.41600 M/S VteorI3 = 113.10000 KM/h pie 5000.0 apgr/min
VteorI4 = 39.27000 M/S VteorI4 = 141.37500 KM/h pie 5000.0 apgr/min
VteorI5 = 52.36000 M/S VteorI5 = 188.50000 KM/h pie 5000.0 apgr/min
VteorI6 = 78.54000 M/S VteorI6 = 282.75000 KM/h pie 5000.0 apgr/min
VteorI1 = 24.68400 M/S VteorI1 = 88.86429 KM/h pie 5500.0 apgr/min
VteorI2 = 28.79800 M/S VteorI2 = 103.67500 KM/h pie 5500.0 apgr/min
VteorI3 = 34.55760 M/S VteorI3 = 124.41000 KM/h pie 5500.0 apgr/min
VteorI4 = 43.19700 M/S VteorI4 = 155.51250 KM/h pie 5500.0 apgr/min
VteorI5 = 57.59600 M/S VteorI5 = 207.35000 KM/h pie 5500.0 apgr/min
VteorI6 = 86.39400 M/S VteorI6 = 311.02500 KM/h pie 5500.0 apgr/min
VteorI1 = 26.92800 M/S VteorI1 = 96.94286 KM/h pie 6000.0 apgr/min
VteorI2 = 31.41600 M/S VteorI2 = 113.10000 KM/h pie 6000.0 apgr/min
VteorI3 = 37.69920 M/S VteorI3 = 135.72000 KM/h pie 6000.0 apgr/min
VteorI4 = 47.12400 M/S VteorI4 = 169.65000 KM/h pie 6000.0 apgr/min
VteorI5 = 62.83200 M/S VteorI5 = 226.20000 KM/h pie 6000.0 apgr/min
VteorI6 = 94.24800 M/S VteorI6 = 339.30000 KM/h pie 6000.0 apgr/min
VteorI1 = 29.17200 M/S VteorI1 = 105.02143 KM/h pie 6500.0 apgr/min
VteorI2 = 34.03400 M/S VteorI2 = 122.52500 KM/h pie 6500.0 apgr/min
VteorI3 = 40.84080 M/S VteorI3 = 147.03000 KM/h pie 6500.0 apgr/min
VteorI4 = 51.05100 M/S VteorI4 = 183.78750 KM/h pie 6500.0 apgr/min
VteorI5 = 68.06800 M/S VteorI5 = 245.05000 KM/h pie 6500.0 apgr/min
VteorI6 = 102.10200 M/S VteorI6 = 367.57500 KM/h pie 6500.0 apgr/min
VteorI1 = 31.41600 M/S VteorI1 = 113.10000 KM/h pie 7000.0 apgr/min
VteorI2 = 36.65200 M/S VteorI2 = 131.95000 KM/h pie 7000.0 apgr/min
VteorI3 = 43.98240 M/S VteorI3 = 158.34000 KM/h pie 7000.0 apgr/min
VteorI4 = 54.97800 M/S VteorI4 = 197.92500 KM/h pie 7000.0 apgr/min
VteorI5 = 73.30400 M/S VteorI5 = 263.90000 KM/h pie 7000.0 apgr/min
VteorI6 = 109.95600 M/S VteorI6 = 395.85000 KM/h pie 7000.0 apgr/min
VteorI1 = 33.66000 M/S VteorI1 = 121.17857 KM/h pie 7500.0 apgr/min
VteorI2 = 39.27000 M/S VteorI2 = 141.37500 KM/h pie 7500.0 apgr/min
VteorI3 = 47.12400 M/S VteorI3 = 169.65000 KM/h pie 7500.0 apgr/min
VteorI4 = 58.90500 M/S VteorI4 = 212.06250 KM/h pie 7500.0 apgr/min
VteorI5 = 78.54000 M/S VteorI5 = 282.75000 KM/h pie 7500.0 apgr/min
VteorI6 = 117.81000 M/S VteorI6 = 424.12500 KM/h pie 7500.0 apgr/min
VteorI1 = 35.90400 M/S VteorI1 = 129.25714 KM/h pie 8000.0 apgr/min
VteorI2 = 41.88800 M/S VteorI2 = 150.80000 KM/h pie 8000.0 apgr/min
VteorI3 = 50.26560 M/S VteorI3 = 180.96000 KM/h pie 8000.0 apgr/min
VteorI4 = 62.83200 M/S VteorI4 = 226.20000 KM/h pie 8000.0 apgr/min
VteorI5 = 83.77600 M/S VteorI5 = 301.60000 KM/h pie 8000.0 apgr/min
VteorI6 = 125.66400 M/S VteorI6 = 452.40000 KM/h pie 8000.0 apgr/min

but I need so the results would be :

Vteor1 ……… 500 apgr/min
Vteor1 ……… 1000 apgr/min
………
Vteor1 ………. 8000 apgr/min

Vteor2………… 500 apgr/min

Vteor2………… 1000 apgr/min

……………

Vteor2 ………… 8000apgr/min

etc.

I’m not sure to understand exactly what would want. But i think you need at less this functions:

``````>> 2.3465.round
=> 2
>> 2.3465.round(2)
=> 2.35
>> 2.3465.round(3)
=> 2.347
``````

And if you need to put a line break in a string you must use a backlash with n
print “Hi\n”

If you got the answer then please share with me also. I have tried haml converter is it good to use or not.

ERB is faster and it easier to understand for someone doing HTML.

There’s no function in Ruby. Everything is a method. Whether Object method, any other class or module method, there’s no function. the `round` is a method on Float objects…