class Discriminant
Public Class Methods
ask()
click to toggle source
# File lib/oops_can.rb, line 5 def self.ask puts "For Learn More About Discriminant Follow ENG http://en.wikipedia.org/wiki/Discriminant" end
make()
click to toggle source
# File lib/oops_can.rb, line 9 def self.make puts "Please input the A: " a = gets.to_i puts "Please input the B: " b = gets.to_i puts "Please input the C: " c = gets.to_i d = (b**2) - (4 * a * c ) puts "Discriminant: #{d}" if d > 0 x1 = (b - (d ** 0.5))/(2 * a) x2 = (b + (d ** 0.5))/(2 * a) puts "x1: #{x1}" puts "x2: #{x2}" # create graph g = Gruff::Dot.new g.title = 'Discriminant have 2 dots' g.labels = { 0 => 'x1', 1 => 'x2', } g.data(:x1, [x1], '#990000') g.data(:x2, [x2], '#990099') g.write('Discriminant.png') elsif d == 0 x = (-b )/(2 * a) puts "x: #{x}" #creating graph g= Gruff::Line.new g.title = 'Discriminant have 1 dot' g.labels = { 0 => 'x' } g.data(:x, [x]) g.write else puts "Not Found X's" end end