9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# 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}"
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}"
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
|