dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

percerr.rb (463B)


      1 #!/usr/bin/env ruby
      2 
      3 puts "Welcome to the Percent Error Calculator."
      4 print "What is your estimated value? >> "
      5 estimated=gets.chomp.to_f
      6 print "What is your measured value? >> "
      7 measured=gets.chomp.to_f
      8 
      9 if estimated>measured
     10 	err=estimated-measured
     11 else
     12 	err=(estimated-measured)*-1
     13 end
     14 
     15 puts "Your error is " + err.to_s + "."
     16 
     17 percerr=(err/measured)*100
     18 
     19 puts "Your percent error is " + percerr.to_s + "%."
     20 puts "Rounded, this is " + percerr.round().to_s + "%."